The proposed solution is just for inputting special char set for a vehicle plate. The original virtual keypad does not satisfy our need.
The interface is simple, function IMCreateInstance() will return an interface pointer.
You just need use the interface pointer to register your Edit control, then the Edit
will have virtual keypad. Before Window being destroyed, you just need use API in
interface pointer to deregister your Edit control.
That's all.
Zhang X.
2010, Sept. 7
===================================================================================
1)定义支持注册和注销虚拟键盘的接口CIMRegister,在DLL中. header file for DLL
- struct IMNode
- {
- UINT id;
- CWnd* parentWnd;
- };
- virtual class CIMRegister
- {
- public:
-
- void RegisterEditControl(IMNode* pNode) = 0;
-
- void DeregisterEditControl(IMNode* pNode) = 0;
- };
- CIMRegister* IMCreateRegisterInstance(...);
2)Implementation in DLL
-
-
- CIMEdit:public CEdit
- {
- public:
- xxxx OnMouseUp()
- {
-
- }
- xxx OnMouseDown()
- {
-
- }
- };
- class CIMRegisterImp:public CIMRegister
- {
- protected:
- CIMRegisterImp(){}
- public:
-
- void RegisterEditControl(IMNode* pNode)
- {
-
-
- }
-
- void DeregisterEditControl(IMNode* pNode)
- {
-
-
-
-
-
- }
- public:
- friend CIMRegister *IMCreateInstance();
- protected:
- CIMEdit* m_pArray[MAX_SUPPORT];
- UINT m_idArray[MAX_SUPPORT];
- int m_num;
- protected:
- static CIMRegisterImp m_sImp;
- };
-
- FAR PASCAL CIMRegister* IMCreateInstance()
- {
- return &(CIMRegisterImp::m_sImp);
- }
-
- class CIMStatic:CStatic
- {
-
-
- virtual class CIMStaticListener
- {
- virtual void OnButtonDown(CIMStatic* pStatic) = 0;
- };
- };
-
- class CIMPad:CDialog, CIMStaticListener
- {
-
-
-
-
-
- };
3)example to use this virtual key pad in dialog CMyDialog
- class CMyDialog::CDialog
- {
- ....
- public:
- xxxx OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- CIMRegister* pReg = IMCreateInstance();
- pReg->RegisterEditControl(...);
- pReg->RegisterEditcontrol(...);
- ...
- }
- xxx OnDestroy()
- {
-
- CIMRegister* pReg = IMCreateInstance();
- pReg->DeregisterEditControl(...);
- pReg->DeregisterEditcontrol(...);
-
- CDialog::OnDestroy();
- }
- };
(xgzhang) |