织梦CMS - 轻松建站从此开始!

罗索

在Windows Mobile实现虚拟键盘的思路 -- 基于DLL实现

jackyhwei 发布于 2011-09-28 13:43 点击:次 
The proposed solution is just for inputting special char set for a vehicle plate. The original virtual keypad does not satisfy our need.
TAG:

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

  1.    struct IMNode 
  2.    { 
  3. UINT id; 
  4.         CWnd* parentWnd; 
  5.    }; 
  6.    virtual class CIMRegister 
  7.    { 
  8.     public
  9.           // call this API when dialog init 
  10.           void RegisterEditControl(IMNode* pNode) = 0; 
  11.           // call this API just before dialog being killed 
  12.           void DeregisterEditControl(IMNode* pNode) = 0; 
  13.    }; 
  14.    CIMRegister* IMCreateRegisterInstance(...); // DLL API 

2)Implementation in DLL

  1.  // a sub-class of CEdit, which support virtual keypard, this is totally transparent to  
  2.  // final user of DLL 
  3.  CIMEdit:public CEdit 
  4.  { 
  5.   public
  6.      xxxx OnMouseUp() 
  7.      { 
  8. // log time, if time difference is less then certain number, launch virtual inputting pad 
  9.      } 
  10.      xxx OnMouseDown() 
  11.      { 
  12.        // log time 
  13.      }   
  14.  }; 
  15. class CIMRegisterImp:public CIMRegister 
  16. protected
  17.       CIMRegisterImp(){}        
  18. public
  19.         // call this API when dialog init 
  20.         void RegisterEditControl(IMNode* pNode) 
  21.         { 
  22.              // check if registered, if not subclass 
  23.              // and add node to array 
  24.         } 
  25.         // call this API just before dialog being killed 
  26.         void DeregisterEditControl(IMNode* pNode) 
  27.         { 
  28.              // check whether in the list 
  29.  
  30.              // if in, directly Destory the control 
  31.              // and remove from array    
  32.  
  33.         } 
  34. public
  35.     friend CIMRegister *IMCreateInstance(); 
  36. protected
  37.     CIMEdit* m_pArray[MAX_SUPPORT]; 
  38.     UINT     m_idArray[MAX_SUPPORT]; 
  39.     int      m_num; 
  40. protected
  41.     static CIMRegisterImp m_sImp; 
  42. }; 
  43.  
  44. FAR PASCAL CIMRegister* IMCreateInstance() 
  45.     return &(CIMRegisterImp::m_sImp);  
  46.  
  47. class CIMStatic:CStatic 
  48.     // this class is used to define virtual key behavior, 
  49.     // derived from CStatic, from CButton is also OK  
  50.     virtual class CIMStaticListener 
  51.     { 
  52.          virtual void OnButtonDown(CIMStatic* pStatic) = 0; 
  53.      };   
  54. }; 
  55.  
  56. class CIMPad:CDialog, CIMStaticListener 
  57.     // virtual key pad implementation, detailed implementation 
  58.     // ignored here    
  59.  
  60.     // dynamically create instance of CIMStatic, and implement 
  61.     // listener of those key, and transfer pressing to Edit input   
  62. }; 

3)example to use this virtual key pad in dialog CMyDialog

 

  1. class CMyDialog::CDialog 
  2.    { 
  3.         .... 
  4.     public
  5.          xxxx OnInitDialog() 
  6.          { 
  7.               CDialog::OnInitDialog(); 
  8.  
  9.               CIMRegister* pReg = IMCreateInstance(); 
  10.               pReg->RegisterEditControl(...); 
  11.               pReg->RegisterEditcontrol(...); 
  12.               ... 
  13.          } 
  14.          xxx OnDestroy() 
  15.           { 
  16.               // call this before CDialog::OnDestroy() 
  17.          CIMRegister* pReg = IMCreateInstance(); 
  18.               pReg->DeregisterEditControl(...); 
  19.               pReg->DeregisterEditcontrol(...); 
  20.  
  21.               CDialog::OnDestroy(); 
  22.           } 
  23.    };  

 

(xgzhang)
本站文章除注明转载外,均为本站原创或编译欢迎任何形式的转载,但请务必注明出处,尊重他人劳动,同学习共成长。转载请注明:文章转载自:罗索实验室 [http://www.rosoo.net/a/201109/15068.html]
本文出处:blog.sina.com.cn/xgzhang 作者:xgzhang
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
栏目列表
将本文分享到微信
织梦二维码生成器
推荐内容