zxj123

zxj123

0个粉丝

92

问答

0

专栏

0

资料

zxj123  发布于  2012-12-24 15:30:38
采纳率 0%
92个问答
4040

evc开发键盘输入程序(输入法)

 
下面的代码是数字输入软件盘:SIP ,IM  一般在wince 下开发方式大致类似 .

开发环境WINCE 5.0 ,evc 4.0,sp4


NumPanel.def



;;Standard COM library DEF file; LIBRARY   NUMPANEL.DLL EXPORTS    DllCanUnloadNow     @1 PRIVATE   DllGetClassObject   @2 PRIVATE   DllRegisterServer   @3 PRIVATE   DllUnregisterServer @4 PRIVATEIMCommon.rc



//======================================================================// Resource file//// Written for the book Programming Windows CE// Copyright (C) 2001 Douglas Boling//======================================================================#include "windows.h"                 // For all that Windows stuff#include "NumPanel.h"                // Program-specific stuff //----------------------------------------------------------------------// Icons and bitmaps//ID_ICON        ICON   "NumPanel.ico" // Module icon NarrowBmp      BITMAP "nkbd.bmp"     // Bmp used in image listNarrowMask     BITMAP "nmask.bmp"    // Mask used in image listWideBmp        BITMAP "widekbd.bmp"  // Bmp used in image listWideMask       BITMAP "widemask.bmp" // Mask used in image listIMCommon.h



//======================================================================// Header file//// Written for the book Programming Windows CE// Copyright (C) 2001 Douglas Boling//======================================================================

#define ID_ICON        1 // **** Start of Generic COM declarations **** //======================================================================// MyClassFactory - Object declaration//class MyClassFactory : public IClassFactory { private:    long m_lRef; public:    MyClassFactory();    ~MyClassFactory();     //IUnknown methods    STDMETHODIMP QueryInterface (THIS_ REFIID riid, LPVOID *ppv);    STDMETHODIMP_(ULONG) AddRef (THIS);    STDMETHODIMP_(ULONG) Release (THIS);     //IClassFactory methods    STDMETHODIMP CreateInstance (LPUNKNOWN pUnkOuter, REFIID riid,                                  LPVOID *ppv);    STDMETHODIMP LockServer (BOOL fLock);};// **** End of Generic OLE declarations ****  //======================================================================// MyIInputMethod - Object declaration//class MyIInputMethod : public IInputMethod2 { private:    long m_lRef;    HWND m_hwndParent;    HWND m_hwndMyWnd;    HIMAGELIST m_himlWide;    HIMAGELIST m_himlNarrow;    IIMCallback *m_pIMCallback; public:    MyIInputMethod();    ~MyIInputMethod();     //IUnknown methods    STDMETHODIMP QueryInterface (THIS_ REFIID riid, LPVOID *ppvObj);

    STDMETHODIMP_(ULONG) AddRef (THIS);    STDMETHODIMP_(ULONG) Release (THIS);     //IInputMethod    HRESULT STDMETHODCALLTYPE Select (HWND hwndSip);    HRESULT STDMETHODCALLTYPE Deselect (void);    HRESULT STDMETHODCALLTYPE Showing (void);    HRESULT STDMETHODCALLTYPE Hiding (void);    HRESULT STDMETHODCALLTYPE GetInfo (IMINFO __RPC_FAR *pimi);    HRESULT STDMETHODCALLTYPE ReceiveSipInfo (SIPINFO __RPC_FAR *psi);    HRESULT STDMETHODCALLTYPE RegisterCallback (                                   IIMCallback __RPC_FAR *lpIMCallback);    HRESULT STDMETHODCALLTYPE GetImData (DWORD dwSize, LPVOID pvImData);    HRESULT STDMETHODCALLTYPE SetImData (DWORD dwSize, LPVOID pvImData);    HRESULT STDMETHODCALLTYPE UserOptionsDlg (HWND hwndParent);     //IInputMethod2    HRESULT STDMETHODCALLTYPE SetIMMActiveContext(HWND hwnd, BOOL bOpen,                        DWORD dwConversion, DWORD dwSentence, DWORD hkl);       HRESULT STDMETHODCALLTYPE RegisterCallback2 (                                    IIMCallback2 RPC_FAR *lpIMCallback);};NumPanel.h



//======================================================================// NPWnd.h - An include file//// Written for the book Programming Windows CE// Copyright (C) 2001 Douglas Boling//====================================================================== #ifdef __cplusplusextern "C"{#endif  // Returns number of elements#define dim(x) (sizeof(x) / sizeof(x[0]))    struct decodeUINT {                            // Structure associates    UINT Code;                                 // messages                                                // with a function.     LRESULT (*Fxn)(HWND, UINT, WPARAM, LPARAM);};  #define MYSIPCLS       TEXT ("MyNumPanelWndCls")#define MYMSG_METHCALL (WM_USER+100)           // Used to pass info#define MSGCODE_REGCALLBACK   0                // Notification codes for#define MSGCODE_GETINFO       1                // MYMSG_METHCALL

#define MSGCODE_SETINFO       2#define MSGCODE_REGCALLBACK2  3 #define GRIPWIDTH      9                       // Width of the gripper#define FLOATWIDTH     200                     // Width of floating wnd#define FLOATHEIGHT    100                     // Height of floating wnd #define CXBTNS         5                       // Num columns of buttons#define CYBTNS         3                       // Num rows of buttons //// Local data structure for keypad IM window//typedef struct {    DWORD dwBtnDnFlags;    IIMCallback *pIMCallback;    IIMCallback2 *pIMCallback2;    RECT rectDocked;    BOOL fMoving;    POINT ptMovBasis;    POINT ptMovStart;    IMINFO imi;    RECT rectLast;} SIPWNDSTRUCT, *LPSIPWNDSTRUCT;INT DrawButton (HDC hdc, RECT *prect, LPTSTR pChar, BOOL fPressed); //// Prototypes for functions implemented by custom IM code//HWND CreateIMWindow (HWND hwndParent);int DestroyIMWindow (HWND hwnd); LRESULT CALLBACK NPWndProc (HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK DoCreateSip (HWND, UINT, WPARAM, LPARAM);LRESULT CALLBACK DoSetSipInfo (HWND, UINT, WPARAM, LPARAM);LRESULT CALLBACK DoPaintSip (HWND, UINT, WPARAM, LPARAM);LRESULT CALLBACK DoMouseSip (HWND, UINT, WPARAM, LPARAM);LRESULT CALLBACK DoDestroySip (HWND, UINT, WPARAM, LPARAM); #ifdef __cplusplus}#endifIMCommon.cpp



//======================================================================// IMCommon - Common code for a Windows CE input method//// Written for the book Programming Windows CE// Copyright (C) 2001 Douglas Boling//======================================================================#include                  // For all that Windows stuff#include                 // Command bar includes#define INITGUID#include #include #include                 // Pocket PC shell includes#include                      // SIP includes #include "IMCommon.h"                // My IM common includes#include "NumPanel.h"                // IM window specific includeslong g_DllCnt = 0;                   // Global DLL reference count extern "C" {HINSTANCE hInst;                     // DLL instance handle}//// GUID defines for my input method.  Create a new one with GUIDGEN.//const GUID CLSID_NumPanel2 = { 0xc8311f61, 0x12df,0x4107,{0xb5,0xea,0xb0,0xb0,0xd5,0x5c,0xec,0x50}}; const TCHAR szCLSIDNumPanel2[] = TEXT ("{C8311F61-12DF-4107-B5EA-B0B0D55CEC50}");const TCHAR szFriendlyName[] = TEXT ("Numeric Keypad"); //======================================================================// DllMain - DLL initialization entry point//BOOL WINAPI DllMain (HANDLE hinstDLL, DWORD dwReason,                      LPVOID lpvReserved) {    hInst = (HINSTANCE)hinstDLL;    return TRUE;}//======================================================================// DllGetClassObject - Exported function called to get pointer to // Class factory object.//

STDAPI DllGetClassObject (REFCLSID rclsid, REFIID riid, LPVOID *ppv) {    MyClassFactory *pcf;    HRESULT hr;     // See if caller wants us.    if (IsEqualCLSID (rclsid, CLSID_NumPanel2)) {         // Create IClassFactory object.        pcf = new MyClassFactory();        if (pcf == NULL)            return E_OUTOFMEMORY;         // Call class factory抯 query interface method.        hr = pcf->QueryInterface (riid, ppv);        // This will cause an obj delete unless interface found.        pcf->Release();        return hr;    }    return CLASS_E_CLASSNOTAVAILABLE;}//======================================================================// DllCanUnloadNow - Exported function called when DLL can unload//STDAPI DllCanUnloadNow () {     if (g_DllCnt)        return S_FALSE;    return S_OK;}//======================================================================// DllRegisterServer - Exported function called to register the server//STDAPI DllRegisterServer () {    TCHAR szName[MAX_PATH+2];    TCHAR szTmp[128];    DWORD dwDisp;    HKEY hKey, hSubKey;    INT rc;     GetModuleFileName (hInst, szName, sizeof (szName));    // Open the key.    wsprintf (szTmp, TEXT ("CLSID\\%s"), szCLSIDNumPanel2);    rc = RegCreateKeyEx (HKEY_CLASSES_ROOT, szTmp, 0, TEXT(""),                          0, 0, NULL, &hKey, &dwDisp);    if (rc != ERROR_SUCCESS)        return E_FAIL;

    // Set the friendly name of the SIP.    RegSetValueEx (hKey, TEXT (""), 0, REG_SZ, (PBYTE)szFriendlyName,                        (lstrlen (szFriendlyName)+1) * sizeof (TCHAR));     // Create subkeys.    // Set the module name of the SIP.    rc = RegCreateKeyEx (hKey, TEXT ("InProcServer32"), 0, TEXT(""),                          0, 0, NULL, &hSubKey, &dwDisp);    rc = RegSetValueEx (hSubKey, TEXT (""), 0, REG_SZ, (PBYTE)szName,                        (lstrlen (szName)+1) * sizeof (TCHAR));    RegCloseKey (hSubKey);     // Set the default icon of the server.    RegCreateKeyEx (hKey, TEXT ("DefaultIcon"), 0, TEXT(""),                     0, 0, NULL, &hSubKey, &dwDisp);    lstrcat (szName, TEXT (",0"));    RegSetValueEx (hSubKey, TEXT (""), 0, REG_SZ, (PBYTE)szName,                   (lstrlen (szName)+1) * sizeof (TCHAR));    RegCloseKey (hSubKey);     // Set the flag indicating this is a SIP.    RegCreateKeyEx (hKey, TEXT ("IsSIPInputMethod"), 0, TEXT(""),                     0, 0, NULL, &hSubKey, &dwDisp);    lstrcpy (szTmp, TEXT ("1"));    RegSetValueEx (hSubKey, TEXT (""), 0, REG_SZ, (PBYTE)szTmp, 4);    RegCloseKey (hSubKey);     RegCloseKey (hKey);    return S_OK;}//======================================================================// DllUnregisterServer - Exported function called to remove the server// information from the registry//STDAPI DllUnregisterServer() {    INT rc;    TCHAR szTmp[128];     wsprintf (szTmp, TEXT ("CLSID\\%s"), szCLSIDNumPanel2);    rc = RegDeleteKey (HKEY_CLASSES_ROOT, szTmp);    if (rc == ERROR_SUCCESS)        return S_OK;    return E_FAIL;}//**********************************************************************// MyClassFactory Object implementation//----------------------------------------------------------------------

// Object constructorMyClassFactory::MyClassFactory () {    m_lRef = 1;     // Set ref count to 1 on create.    return;}//----------------------------------------------------------------------// Object destructorMyClassFactory::~MyClassFactory () {    return;}//----------------------------------------------------------------------// QueryInterface - Called to see what interfaces this object supportsSTDMETHODIMP MyClassFactory::QueryInterface (THIS_ REFIID riid,                                              LPVOID *ppv) {     // If caller wants our IUnknown or IClassFactory object,     // return a pointer to the object.    if (IsEqualIID (riid, IID_IUnknown) ||         IsEqualIID (riid, IID_IClassFactory)) {         *ppv = (LPVOID)this;     // Return pointer to object.        AddRef();                // Increment ref to prevent delete on return.        return NOERROR;    }    *ppv = NULL;    return (E_NOINTERFACE);}//----------------------------------------------------------------------// AddRef - Increment object ref count.STDMETHODIMP_(ULONG) MyClassFactory::AddRef (THIS) {    ULONG cnt;     cnt = (ULONG)InterlockedIncrement (&m_lRef);    return cnt;}//----------------------------------------------------------------------// Release - Decrement object ref count.STDMETHODIMP_(ULONG) MyClassFactory::Release (THIS) {    ULONG cnt;     cnt = (ULONG)InterlockedDecrement (&m_lRef);    if (cnt == 0)        delete this;    return cnt;}
我来回答
回答0个
时间排序
认可量排序
易百纳技术社区暂无数据
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
+ 添加网盘链接/附件

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
举报反馈

举报类型

  • 内容涉黄/赌/毒
  • 内容侵权/抄袭
  • 政治相关
  • 涉嫌广告
  • 侮辱谩骂
  • 其他

详细说明

易百纳技术社区