imm.c
上传用户:szljw888
上传日期:2010-04-11
资源大小:124k
文件大小:18k
源码类别:

输入法编程

开发平台:

C/C++

  1. /* 大熊猫输入法(Free Chinese Input)  由YJMSIR(yjmsir@163.com)编写
  2.  * 协议: GPL
  3.  * freeinput( A Chinese Input Method) by YJMSIR(yjmsir@163.com)
  4.  * Licence: GPL 
  5.  */
  6. #include "freepy.h"
  7. BOOL WINAPI ImeInquire(LPIMEINFO lpIMEInfo,LPTSTR lpszUIClass,LPCTSTR lpszOption)
  8. {
  9. //DebugLog(1,(DebugLogFile,"ImeInquiren"));
  10.     lpIMEInfo->dwPrivateDataSize = sizeof(UIEXTRA);
  11.     lpIMEInfo->fdwProperty = IME_PROP_KBD_CHAR_FIRST |
  12. #ifdef _UNICODE
  13.                              IME_PROP_UNICODE |
  14. #endif
  15.                              IME_PROP_SPECIAL_UI;
  16.     lpIMEInfo->fdwConversionCaps = IME_CMODE_FULLSHAPE |
  17. IME_CMODE_NATIVE;
  18.     lpIMEInfo->fdwSentenceCaps = IME_SMODE_NONE;
  19.     lpIMEInfo->fdwUICaps = UI_CAP_2700;
  20. lpIMEInfo->fdwSCSCaps = 0;
  21.     lpIMEInfo->fdwSelectCaps = SELECT_CAP_CONVERSION;
  22.     _tcscpy(lpszUIClass,UICLASSNAME);
  23.     return TRUE;
  24. }
  25. BOOL WINAPI ImeConfigure(HKL hKL,HWND hWnd, DWORD dwMode, LPVOID lpData)
  26. {
  27. //DebugLog(1,(DebugLogFile,"ImeConfiguren"));
  28. DialogBox( hInst,MAKEINTRESOURCE(DIALOGSET),hWnd,SetDialogProc);
  29. InvalidateRect(hWnd,NULL,FALSE);
  30. return TRUE;
  31. }
  32. DWORD WINAPI ImeConversionList(HIMC hIMC,LPCTSTR lpSource,LPCANDIDATELIST lpCandList,DWORD dwBufLen,UINT uFlag)
  33. {
  34. //DebugLog(1,(DebugLogFile,"ImeConversionListn"));
  35.     return 0;
  36. }
  37. BOOL WINAPI ImeDestroy(UINT uForce)
  38. {
  39. //DebugLog(1,(DebugLogFile,"ImeDestroyn"));
  40.     return FALSE;
  41. }
  42. LRESULT WINAPI ImeEscape(HIMC hIMC,UINT uSubFunc,LPVOID lpData)
  43. {
  44. //DebugLog(1,(DebugLogFile,"ImeEscapen"));
  45. return FALSE;
  46. }
  47. BOOL WINAPI ImeProcessKey(HIMC hIMC,UINT vKey,LPARAM lKeyData,CONST LPBYTE lpbKeyState)
  48. {
  49.     BOOL fRet = FALSE;
  50.     BOOL fOpen;
  51.     BOOL fCompStr = FALSE;
  52.     LPINPUTCONTEXT lpIMC;
  53. LPCANDIDATEINFO lpCandInfo;
  54. LPCANDIDATELIST lpCandList;
  55.     LPCOMPOSITIONSTRING lpCompStr;
  56. static BOOL fPressOther = FALSE;
  57. static BOOL fFirst = TRUE;
  58. // //DebugLog(1,(DebugLogFile,"ImeProcessKeyn"));
  59.     /*if ((lKeyData & 0x80000000) && vKey != VK_CONTROL)
  60.         return FALSE;
  61. if (!(lKeyData & 0x80000000) && vKey == VK_CONTROL)
  62. return FALSE;
  63. if (lpbKeyState[VK_MENU] & 0x80 ) {
  64. return FALSE;
  65. }*/
  66. //随着ALT键的按次,lpbKeyState[VK_MENU]在0与1间变换
  67. //DebugLog(2,(DebugLogFile,"vKey:%x, lpbKeyState[VK_CONTROL]:%xn",vKey,lpbKeyState[VK_CONTROL]));
  68.     if (!(lpIMC = ImmLockIMC(hIMC)))
  69.         return FALSE;
  70. //ctrl+`切换成五笔
  71. if(vKey == 0xc0 && lpbKeyState[VK_CONTROL] & 0x80 ){
  72. TurnIntoWubiMode(hIMC);
  73. HotKeyPressed=1;
  74. return 1;
  75. // return FALSE;
  76. }
  77. //ctrl+tab切换成拼音
  78. if(vKey == 0x9 && lpbKeyState[VK_CONTROL] & 0x80 ){
  79. TurnIntoPinyinMode(hIMC);
  80. HotKeyPressed=1;
  81. return 1;//FALSE;
  82. }
  83. //ctrl+切换五笔与拼音
  84. if(vKey == 0xdc && lpbKeyState[VK_CONTROL] & 0x80 ){
  85. static i=0; i++;if(i<2) return FALSE;i=0;
  86. ToggleConversionMode(hIMC);
  87. HotKeyPressed=1;
  88. return 1;
  89. // return 0;
  90. }
  91. //ctrl+m  gbk模式
  92. if(vKey == 0x4d && lpbKeyState[VK_CONTROL] & 0x80 ){
  93. //static i=0; i++;if(i<2) return FALSE;i=0;
  94. if( wConversionSet & CONVERSION_SET_GBK)
  95. MessageBoxPrintf(_T("切换gbk"),_T("到gb2312"));
  96. else MessageBoxPrintf(_T("切换gb2312"),_T("到gbk"));
  97. ToggleConversionSet(CONVERSION_SET_GBK);
  98. UpdateStatusByMessage(hIMC);
  99. HotKeyPressed=1;
  100. return 1;
  101. }
  102. //_T('j')//ctrl+shift+j 日本字功能
  103. if(vKey == 0x48 && lpbKeyState[VK_SHIFT] & 0x80 && lpbKeyState[VK_CONTROL] & 0x80 ){
  104. ToggleConversionSet(CONVERSION_SET_JP);
  105. HotKeyPressed=1;
  106. return 1;
  107. // return FALSE;
  108. }
  109. //ctrl+j输简得繁功能
  110. if(vKey == 0x48 && lpbKeyState[VK_CONTROL] & 0x80 ){
  111. ToggleConversionSet(CONVERSION_SET_GBJT2FT);
  112. HotKeyPressed=1;
  113. return 1;
  114. // return FALSE;
  115. }
  116. //_T('')//ctrl+shift+ 大五码功能
  117. if(vKey == 0xdc && lpbKeyState[VK_SHIFT] & 0x80 && lpbKeyState[VK_CONTROL] & 0x80 ){
  118. ToggleConversionSet(CONVERSION_SET_BIG5);
  119. HotKeyPressed=1;
  120. return 1;
  121. // return FALSE;
  122. }
  123. //_T('.')中西文标点切换
  124. if(vKey == 0xbe && lpbKeyState[VK_CONTROL] & 0x80 ){
  125. static i=0; i++;if(i<2) return FALSE;i=0;
  126. ToggleConversionSet(CONVERSION_SET_PUNCT);
  127. UpdateStatusByMessage(hIMC);
  128. HotKeyPressed=1;
  129. return 1;
  130. // return FALSE;
  131. }
  132. //shift+space全角半角字符切换
  133. if(vKey == 0x20 && lpbKeyState[VK_SHIFT] & 0x80 ){
  134. static i=0; i++;if(i<2) return FALSE;i=0;
  135. ToggleConversionSet(CONVERSION_SET_FULLSHAPE);
  136. UpdateStatusByMessage(hIMC);
  137. HotKeyPressed=1;
  138. return 1;
  139. // return FALSE;
  140. }
  141. //ctrl+/取得五笔编码
  142. if(vKey == 0xbf && lpbKeyState[VK_CONTROL] & 0x80 &&
  143. wConversionSet &CONVERSION_SET_USEWB){
  144. ReturnWuBicode(hIMC);
  145. HotKeyPressed=1;
  146. return 1;
  147. }
  148. //以上是各种状态通用快捷键
  149. //以下为五笔状态专用快捷键
  150. if(wConversionMode == CONVERSION_MODE_WUBI){
  151. if((vKey == 0xba|| vKey == 0x44)&& lpbKeyState[VK_CONTROL] & 0x80 ){//ctrl+;或者d剪贴板造词
  152. MakeWordFromClipboard(hIMC);
  153. HotKeyPressed=1;
  154. return 1;
  155. }
  156. if(vKey == 0xbb && lpbKeyState[VK_CONTROL] & 0x80 ){//ctrl++在线造词
  157. TurnIntoWubiModeAdd(hIMC);
  158. HotKeyPressed=1;
  159. return 1;
  160. //return FALSE;
  161. }
  162. if(vKey == 0xbd && lpbKeyState[VK_CONTROL] & 0x80 ){//ctrl+-在线删词
  163. LPTSTR lpPreResultStr;
  164. lpCompStr = (LPCOMPOSITIONSTRING)ImmLockIMCC(lpIMC->hCompStr);
  165. lpPreResultStr = ((LPMYCOMPSTR)lpCompStr)->FreePYComp.szPreResultStr;
  166. MessageBoxPrintf(_T("删除词库内的词组"),_T("编码:%sn词组:%s"),
  167. szPreResultCode, lpPreResultStr);
  168. DeleteWbPhrase (szPreResultCode, lpPreResultStr);
  169. HotKeyPressed=1;
  170. return 1;
  171. }
  172. if(vKey == 0x49 && lpbKeyState[VK_CONTROL] & 0x80 ){//ctrl+i用户词库加入系统词库
  173. TurnUserWordIntoSys();
  174. HotKeyPressed=1;
  175. return 1;
  176. }
  177. if(vKey >=0x30 && vKey <=0x39 && lpbKeyState[VK_SHIFT] & 0x80 &&
  178. lpbKeyState[VK_CONTROL] & 0x80 ){//ctrl+shift+0-9在线删词键
  179. DWORD dwIdx;
  180. LPTSTR lpConvStr;
  181. lpCandInfo = (LPCANDIDATEINFO)ImmLockIMCC(lpIMC->hCandInfo);
  182. lpCandList = (LPCANDIDATELIST)((LPSTR)lpCandInfo  + lpCandInfo->dwOffset[0]);
  183. lpCompStr = (LPCOMPOSITIONSTRING)ImmLockIMCC(lpIMC->hCompStr);
  184. if( vKey == (WORD)_T('0')) 
  185. dwIdx=9;
  186. else 
  187. dwIdx = vKey - _T('1');
  188. if(dwIdx < lpCandList->dwPageSize ) {
  189. dwIdx += lpCandList->dwPageStart;
  190. if( dwIdx < (lpCandList->dwCount + 2) && lpCandList->dwCount){
  191. lpConvStr = ((LPMYCOMPSTR)lpCompStr)->FreePYComp.szConvCompStr;
  192. _tcscpy(lpConvStr,GETLPCANDSTR(lpCandList,dwIdx));
  193. DeleteWbPhrase (szPreResultCode, lpConvStr);
  194. MakeResultString(hIMC,FALSE);
  195. }
  196. }
  197. HotKeyPressed=1;
  198. return 1;
  199. // return FALSE;
  200. }
  201. //ctrl+0-9//在线高频键
  202. if(vKey >=0x30 && vKey <=0x39 && lpbKeyState[VK_CONTROL] & 0x80 ){
  203. WORD wIdx;
  204. lpCandInfo = (LPCANDIDATEINFO)ImmLockIMCC(lpIMC->hCandInfo);
  205. lpCandList = (LPCANDIDATELIST)((LPSTR)lpCandInfo  + lpCandInfo->dwOffset[0]);
  206. if(vKey==0x30) wIdx=9;
  207. else wIdx=vKey-0x31;
  208. wIdx=wIdx+(WORD)lpCandList->dwPageStart-2;
  209. AdjustOrderByIndexToNo1(wIdx,GETLPCANDSTR(lpCandList,wIdx));
  210. MakeResultString(hIMC,FALSE);//清空
  211. ImmUnlockIMCC(lpIMC->hCandInfo);
  212. HotKeyPressed=1;
  213. return 1;
  214. // return FALSE;
  215. }
  216. //ctrl+'切换词库
  217. if(vKey == 0xde && lpbKeyState[VK_CONTROL] & 0x80 ){
  218. TurnToNextWordLib(0);
  219. UpdateIcontheme();
  220. //UpdateStatusByMessage(hIMC);
  221. CreateStatusByMessage(hIMC);
  222. HotKeyPressed=1;
  223. return 1;
  224. }
  225. /*
  226. //ctrl+tab切换成拼音
  227. if(vKey == 0x9 && lpbKeyState[VK_CONTROL] & 0x80 ){
  228. TurnIntoPinyinMode(hIMC);
  229. HotKeyPressed=1;
  230. return 1;//FALSE;
  231. }
  232. if(vKey == 0x9 && lpbKeyState[VK_SHIFT] & 0x80 ){//shift+tab向前翻页
  233. lpCandInfo = (LPCANDIDATEINFO)ImmLockIMCC(lpIMC->hCandInfo);
  234. lpCandList = (LPCANDIDATELIST)((LPSTR)lpCandInfo  + lpCandInfo->dwOffset[0]);
  235. SelectBackwardFromCand(hIMC,lpCandList);
  236. ImmUnlockIMCC(lpIMC->hCandInfo);
  237. return FALSE;//
  238. }
  239. if(vKey == 0x9){//tab向后翻页
  240. lpCandInfo = (LPCANDIDATEINFO)ImmLockIMCC(lpIMC->hCandInfo);
  241. lpCandList = (LPCANDIDATELIST)((LPSTR)lpCandInfo  + lpCandInfo->dwOffset[0]);
  242. SelectForwardFromCand(hIMC,lpCandList);
  243. ImmUnlockIMCC(lpIMC->hCandInfo);
  244. return FALSE;
  245. } */
  246. }
  247. /* if (vKey != VK_SHIFT &&lpbKeyState[VK_SHIFT] & 0x80){
  248. char ayjm[50],cyjm[150];
  249. _stprintf(ayjm,"vKey:%x lpbKeyState[VK_CAPITAL]:%x lKeyData:%x ",vKey,lpbKeyState[VK_CAPITAL],lKeyData);
  250. _stprintf(cyjm,"lpbKeyState[VK_CONTROL]:%xn lpbKeyState[VK_MENU]:%xn lpbKeyState[VK_SHIFT]:%xn",
  251.   lpbKeyState[VK_CONTROL],lpbKeyState[VK_MENU],lpbKeyState[VK_SHIFT]);
  252. MessageBox(NULL,cyjm,ayjm,MB_OK);
  253. return FALSE;
  254. }*///10,360001,
  255. if(vKey != VK_CONTROL && lpbKeyState[VK_CONTROL] & 0x80 ) {
  256. fPressOther = TRUE;
  257. return FALSE;
  258. }
  259. //随着CONTROL键的按次,lpbKeyState[CONTROL]在80与81间变换
  260.     //if (!(lpIMC = ImmLockIMC(hIMC)))
  261.    //     return FALSE;
  262.     fOpen = lpIMC->fOpen;
  263. //if(vKey == VK_CONTROL && (lKeyData & 0x80000000) && !fPressOther && !fFirst){
  264. if(vKey == 0x10 && (lpbKeyState[VK_SHIFT] & 0x80) && (lKeyData==0x360001)){
  265. GENEMSG GnMsg;//右shift中英文切换
  266. fPressOther = FALSE;
  267. if(fOpen) {
  268. lpIMC->fOpen=FALSE;
  269. MakeResultString(hIMC,FALSE);
  270. }
  271. else lpIMC->fOpen=TRUE;
  272. GnMsg.msg = WM_IME_NOTIFY;
  273. GnMsg.wParam = IMN_SETOPENSTATUS;
  274. GnMsg.lParam = 0;
  275. GenerateMessage(hIMC, lpdwCurTransKey,(LPGENEMSG)&GnMsg);
  276. return FALSE;
  277. }
  278. fPressOther = FALSE;
  279. if(fFirst) fFirst = FALSE;
  280. /*
  281. //if CapsLock is pressed ,then return false;
  282. if (lpbKeyState[VK_CAPITAL] & 0x01) {
  283. wPreConversionMode =wConversionMode;
  284. wConversionMode =CONVERSION_MODE_CAPITAL;
  285. return FALSE;
  286. }
  287. //随着VK_CAPITAL键的按次,lpbKeyState[VK_CAPITAL]在80与81间变换
  288.     if (fOpen)
  289.     {
  290.         if (lpCompStr = (LPCOMPOSITIONSTRING)ImmLockIMCC(lpIMC->hCompStr))
  291.         {
  292.             if ((lpCompStr->dwSize > sizeof(COMPOSITIONSTRING)) && 
  293.                 (lpCompStr->dwCompStrLen))
  294.                 fCompStr = TRUE;
  295. ImmUnlockIMCC(lpIMC->hCompStr);
  296.         }
  297. if (dwConversionMode & CONVERSION_MODE_FULLSHAPE){
  298. if (lpbKeyState[VK_SHIFT] & 0x80)
  299.     {
  300.     if (fCompStr)
  301.     fRet = (BOOL)bFullCompSht[vKey];
  302. else
  303. fRet = (BOOL)bFullNoCompSht[vKey];
  304. }
  305. else 
  306. {
  307. if (fCompStr)
  308. fRet = (BOOL)bFullComp[vKey];
  309. else
  310. fRet = (BOOL)bFullNoComp[vKey];
  311. }
  312. }
  313. else{
  314. if (lpbKeyState[VK_SHIFT] & 0x80)
  315.     {
  316.     if (fCompStr)
  317.     fRet = (BOOL)bCompSht[vKey];
  318. else
  319. fRet = (BOOL)bNoCompSht[vKey];
  320. }
  321. else 
  322. {
  323. if (fCompStr)
  324. fRet = (BOOL)bComp[vKey];
  325. else
  326. fRet = (BOOL)bNoComp[vKey];
  327. }
  328. }
  329.     }
  330. */
  331.     if (fOpen)
  332.     {
  333.         if (lpCompStr = (LPCOMPOSITIONSTRING)ImmLockIMCC(lpIMC->hCompStr))
  334.         {
  335.             if ((lpCompStr->dwSize > sizeof(COMPOSITIONSTRING)) && 
  336.                 (lpCompStr->dwCompStrLen))
  337.                 fCompStr = TRUE;
  338. ImmUnlockIMCC(lpIMC->hCompStr);
  339.         }
  340. if (fCompStr)
  341. fRet = (BOOL)bComp[vKey];
  342. else
  343. fRet = (BOOL)bNoComp[vKey];
  344. }
  345.     ImmUnlockIMC(hIMC);
  346. /* if(1){
  347. char ayjm[50];
  348. _stprintf(ayjm,"vKey:%x,fRet:%d",vKey,fRet);
  349. MessageBox(NULL,ayjm,"",MB_OK);
  350. }*/
  351.     return fRet;
  352.     //ImmUnlockIMC(hIMC);
  353. //return 1;
  354. }
  355. BOOL WINAPI ImeSelect(HIMC hIMC, BOOL fSelect)
  356. {
  357.     LPINPUTCONTEXT lpIMC;
  358.     if (fSelect)
  359.         UpdateIndicIcon(hIMC);
  360.     // it's NULL context.
  361.     if (!hIMC)
  362.         return TRUE;
  363.     if (lpIMC = ImmLockIMC(hIMC))
  364.     {
  365.         if (fSelect)
  366.         {
  367.             LPCOMPOSITIONSTRING lpCompStr;
  368.             LPCANDIDATEINFO lpCandInfo;
  369. DWORD dwData = sizeof(DWORD);
  370. BOOL fFlag = TRUE;
  371. lpIMC->fOpen=TRUE;
  372.             lpIMC->hCompStr = ImmReSizeIMCC(lpIMC->hCompStr,sizeof(MYCOMPSTR));
  373.             if (lpCompStr = (LPCOMPOSITIONSTRING)ImmLockIMCC(lpIMC->hCompStr)) 
  374.             {
  375. InitCompStr(lpCompStr);
  376.                 ImmUnlockIMCC(lpIMC->hCompStr);
  377.             }
  378.             lpIMC->hCandInfo = ImmReSizeIMCC(lpIMC->hCandInfo,sizeof(MYCAND));
  379.             if (lpCandInfo = (LPCANDIDATEINFO)ImmLockIMCC(lpIMC->hCandInfo)) 
  380.             {
  381. InitCandInfo(lpCandInfo);
  382.                 ImmUnlockIMCC(lpIMC->hCandInfo);
  383.             }
  384. ReadUserIni();
  385. fFlag = FALSE;
  386. if( fFlag) {//如果读取注册表失败,则选择
  387. wConversionSet |= CONVERSION_SET_PUNCT;//中文标点
  388. wConversionSet |= CONVERSION_SET_SORT;//自动调整
  389. wConversionSet |= CONVERSION_SET_FOLLOW;//光标跟随
  390. wConversionSet |= CONVERSION_SET_GBK;//gbk码
  391. wConversionMode=CONVERSION_MODE_PINYIN;//拼音
  392. }
  393.         }
  394.     }
  395.     ImmUnlockIMC(hIMC);
  396.     return TRUE;
  397. }
  398. BOOL WINAPI ImeSetActiveContext(HIMC hIMC,BOOL fFlag)
  399. {
  400. //DebugLog(1,(DebugLogFile,"ImeSetActiveContextn"));
  401.     UpdateIndicIcon(hIMC);
  402.     return TRUE;
  403. }
  404. UINT WINAPI ImeToAsciiEx (UINT uVKey,UINT uScanCode,CONST LPBYTE lpbKeyState,
  405.   LPDWORD lpdwTransKey,UINT fuState,HIMC hIMC)
  406. {
  407.     LPARAM lParam;
  408.     LPINPUTCONTEXT lpIMC;
  409.     BOOL fOpen;
  410.     //LPINPUTCONTEXT lpIMC;
  411. //LPCANDIDATEINFO lpCandInfo;
  412. //LPCANDIDATELIST lpCandList;
  413.     if (!(lpIMC = ImmLockIMC(hIMC)))
  414.         return FALSE;
  415. // //DebugLog(1,(DebugLogFile,"ImeToAsciiExn"));
  416. /*/ if (wParam != VK_SHIFT &&lpbKeyState[VK_SHIFT] & 0x80){
  417. if(1){
  418. char ayjm[50],cyjm[150];
  419. _stprintf(ayjm,"vKey1:%x lpbKeyState[VK_CAPITAL]:%x lKeyData:%x ",uVKey,lpbKeyState[VK_CAPITAL],uScanCode);
  420. _stprintf(cyjm,"lpbKeyState[VK_CONTROL]:%xn lpbKeyState[VK_MENU]:%xn lpbKeyState[VK_SHIFT]:%xn",
  421.   lpbKeyState[VK_CONTROL],lpbKeyState[VK_MENU],lpbKeyState[VK_SHIFT]);
  422. MessageBox(NULL,cyjm,ayjm,MB_OK);
  423. return FALSE;
  424. }*///10,360001,
  425. /* if(uVKey == 0x9 && lpbKeyState[VK_SHIFT] & 0x80 ){//shift+tab向前翻页
  426. lpCandInfo = (LPCANDIDATEINFO)ImmLockIMCC(lpIMC->hCandInfo);
  427. lpCandList = (LPCANDIDATELIST)((LPSTR)lpCandInfo  + lpCandInfo->dwOffset[0]);
  428. SelectBackwardFromCand(hIMC,lpCandList);
  429. ImmUnlockIMCC(lpIMC->hCandInfo);
  430. return FALSE;//
  431. }
  432. if(uVKey == 0x9){//tab向后翻页
  433. lpCandInfo = (LPCANDIDATEINFO)ImmLockIMCC(lpIMC->hCandInfo);
  434. lpCandList = (LPCANDIDATELIST)((LPSTR)lpCandInfo  + lpCandInfo->dwOffset[0]);
  435. SelectForwardFromCand(hIMC,lpCandList);
  436. ImmUnlockIMCC(lpIMC->hCandInfo);
  437. //YJMStopInput=1;
  438. return FALSE;
  439. }*/
  440.     lpdwCurTransKey = lpdwTransKey;
  441.     lParam = ((DWORD)uScanCode << 16) + 1L;
  442.     
  443.     // Init uNumTransKey here.
  444.     uNumTransKey = 0;
  445.     // if hIMC is NULL, this means DISABLE IME.
  446.     if (!hIMC)
  447.         return 0;
  448.     if (!(lpIMC = ImmLockIMC(hIMC)))
  449.         return 0;
  450.     fOpen = lpIMC->fOpen;
  451.     ImmUnlockIMC(hIMC);
  452.     // The current status of IME is "closed".
  453.     if (!fOpen)
  454.         goto my_exit;
  455.     if (uScanCode & 0x8000)
  456.         IMEKeyupHandler( hIMC, uVKey, lParam, lpbKeyState);
  457.     else
  458.         IMEKeydownHandler( hIMC, uVKey, lParam, lpbKeyState);
  459.     // Clear static value, no more generated message!
  460.     lpdwCurTransKey = NULL;
  461. my_exit:
  462.     // If trans key buffer that is allocated by USER.EXE full up,
  463.     // the return value is the negative number.
  464.     if (fOverTransKey)
  465.     {
  466.         return (int)uNumTransKey;
  467.     }
  468.     return (int)uNumTransKey;
  469. }
  470. BOOL WINAPI NotifyIME(HIMC hIMC,DWORD dwAction,DWORD dwIndex,DWORD dwValue)
  471. {
  472.     BOOL bRet = FALSE;
  473. LPINPUTCONTEXT lpIMC;
  474. //DebugLog(1,(DebugLogFile,"NotifyIMEn"));
  475.     switch(dwAction)
  476.     {
  477. case NI_OPENCANDIDATE:
  478. //DebugLog(1,(DebugLogFile,"NotifyIME:NI_OPENCANDIDATEn"));
  479. break;
  480. case NI_CLOSECANDIDATE:
  481. //DebugLog(1,(DebugLogFile,"NotifyIME:NI_CLOSECANDIDATEn"));
  482. break;
  483. case NI_SELECTCANDIDATESTR:
  484. //DebugLog(1,(DebugLogFile,"NotifyIME:NI_SELECTCANDIDATESTRn"));
  485. break;
  486. case NI_CHANGECANDIDATELIST:
  487. //DebugLog(1,(DebugLogFile,"NotifyIME:NI_CHANGECANDIDATELISTn"));
  488. break;
  489. case NI_SETCANDIDATE_PAGESTART:
  490. //DebugLog(1,(DebugLogFile,"NotifyIME:NI_SETCANDIDATE_PAGESTARTn"));
  491. break;
  492. case NI_SETCANDIDATE_PAGESIZE:
  493. //DebugLog(1,(DebugLogFile,"NotifyIME:NI_SETCANDIDATE_PAGESIZEn"));
  494. break;
  495. case NI_CONTEXTUPDATED:
  496. //DebugLog(1,(DebugLogFile,"NotifyIME:NI_CONTEXTUPDATEDn"));
  497. switch (dwValue)
  498. {
  499. case IMC_SETCONVERSIONMODE:
  500. //DebugLog(1,(DebugLogFile,"NotifyIME:NI_CONTEXTUPDATED:IMC_SETCONVERSIONMODEn"));
  501. break;
  502. case IMC_SETSENTENCEMODE:
  503. //DebugLog(1,(DebugLogFile,"NotifyIME:NI_CONTEXTUPDATED:IMC_SETSENTENCEMODEn"));
  504. break;
  505. case IMC_SETCANDIDATEPOS:
  506. //DebugLog(1,(DebugLogFile,"NotifyIME:NI_CONTEXTUPDATED:IMC_SETCANDIDATEPOSn"));
  507. break;
  508. case IMC_SETCOMPOSITIONFONT:
  509. //DebugLog(1,(DebugLogFile,"NotifyIME:NI_CONTEXTUPDATED:IMC_SETCOMPOSITIONFONTn"));
  510. break;
  511. case IMC_SETCOMPOSITIONWINDOW:
  512. //DebugLog(1,(DebugLogFile,"NotifyIME:NI_CONTEXTUPDATED:IMC_SETCOMPOSITIONWINDOWn"));
  513. break;
  514. case IMC_SETOPENSTATUS:
  515. //DebugLog(1,(DebugLogFile,"NotifyIME:NI_CONTEXTUPDATED:IMC_SETOPENSTATUSn"));
  516. lpIMC = ImmLockIMC(hIMC);
  517. if (lpIMC)
  518. {
  519. if (!lpIMC->fOpen && IsCompStr(hIMC))
  520. MakeResultString( hIMC,FALSE);
  521. ImmUnlockIMC(hIMC);
  522. }
  523. UpdateIndicIcon(hIMC);
  524. bRet = TRUE;
  525. break;
  526. default:
  527. break;
  528. }
  529. break;
  530. case NI_COMPOSITIONSTR:
  531. //DebugLog(1,(DebugLogFile,"NotifyIME:NI_COMPOSITIONSTRn"));
  532. switch (dwIndex)
  533. {
  534. case CPS_COMPLETE:
  535. //DebugLog(1,(DebugLogFile,"NotifyIME:NI_COMPOSITIONSTR:CPS_COMPLETEn"));
  536. break;
  537. case CPS_CONVERT:
  538. //DebugLog(1,(DebugLogFile,"NotifyIME:NI_COMPOSITIONSTR:CPS_CONVERTn"));
  539. break;
  540. case CPS_REVERT:
  541. //DebugLog(1,(DebugLogFile,"NotifyIME:NI_COMPOSITIONSTR:CPS_REVERTn"));
  542. break;
  543. case CPS_CANCEL:
  544. //DebugLog(1,(DebugLogFile,"NotifyIME:NI_COMPOSITIONSTR:CPS_CANCELn"));
  545. break;
  546. default:
  547. break;
  548. }
  549. break;
  550. default:
  551. break;
  552.     }
  553.     return bRet;
  554. }
  555. BOOL WINAPI ImeRegisterWord(LPCTSTR lpRead, DWORD dw, LPCTSTR lpStr)
  556. {
  557. //DebugLog(1,(DebugLogFile,"ImeRegisterWordn"));
  558.     return FALSE;
  559. }
  560. BOOL WINAPI ImeUnregisterWord(LPCTSTR lpRead, DWORD dw, LPCTSTR lpStr)
  561. {
  562. //DebugLog(1,(DebugLogFile,"ImeUnregisterWordn"));
  563.     return FALSE;
  564. }
  565. UINT WINAPI ImeGetRegisterWordStyle(UINT nItem, LPSTYLEBUF lp)
  566. {
  567. //DebugLog(1,(DebugLogFile,"ImeGetRegisterWordStylen"));
  568. return 0;
  569. }
  570. UINT WINAPI ImeEnumRegisterWord(REGISTERWORDENUMPROC lpfn, LPCTSTR lpRead, DWORD dw, LPCTSTR lpStr, LPVOID lpData)
  571. {
  572. //DebugLog(1,(DebugLogFile,"ImeEnumRegisterWordn"));
  573. return 0;
  574. }
  575. BOOL WINAPI ImeSetCompositionString(HIMC hIMC, DWORD dwIndex, LPCVOID lpComp, DWORD dwComp, LPCVOID lpRead, DWORD dwRead)
  576. {
  577. //DebugLog(1,(DebugLogFile,"ImeSetCompositionStringn"));
  578.     return FALSE;
  579. }