MODE.C
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:5k
源码类别:

Windows编程

开发平台:

Visual C++

  1. /**********************************************************************/
  2. /*                                                                    */
  3. /*      MODE.C                                                        */
  4. /*                                                                    */
  5. /*      Copyright (c) 1995-1997  Microsoft Corporation                */
  6. /*                                                                    */
  7. /**********************************************************************/
  8. #include "windows.h"
  9. #include "imm.h"
  10. #include "resource.h"
  11. #include "imeapps.h"
  12. LRESULT HandleModeCommand(HWND hWnd,WPARAM wParam,LPARAM lParam)
  13. {
  14.     HIMC hIMC = ImmGetContext(hWndCompStr);
  15.     DWORD dwConv, dwSent;
  16.     DWORD dwTemp;
  17.     ImmGetConversionStatus(hIMC,&dwConv,&dwSent);
  18.     switch(LOWORD(wParam))
  19.     {
  20.         case IDM_NATIVEMODE:
  21.             dwTemp = dwConv & ~IME_CMODE_LANGUAGE;
  22.             switch (dwConv & IME_CMODE_LANGUAGE)
  23.             {
  24.                 case IME_CMODE_ALPHANUMERIC:
  25.                     dwTemp |= IME_CMODE_NATIVE;
  26.                     break;
  27.                 case IME_CMODE_NATIVE:
  28.                     dwTemp |= (IME_CMODE_NATIVE | IME_CMODE_KATAKANA);
  29.                     break;
  30.                 case (IME_CMODE_NATIVE | IME_CMODE_KATAKANA):
  31.                 default:
  32.                     break;
  33.             }
  34.             dwConv = dwTemp;
  35.             break;
  36.         case IDM_FULLHALF:
  37.             if (dwConv & IME_CMODE_FULLSHAPE)
  38.                 dwConv &= ~IME_CMODE_FULLSHAPE;
  39.             else
  40.                 dwConv |= IME_CMODE_FULLSHAPE;
  41.             break;
  42.         case IDM_ROMAN:
  43.             if (dwConv & IME_CMODE_ROMAN)
  44.                 dwConv &= ~IME_CMODE_ROMAN;
  45.             else
  46.                 dwConv |= IME_CMODE_ROMAN;
  47.             break;
  48.         case IDM_CHARCODE:
  49.             if (dwConv & IME_CMODE_CHARCODE)
  50.                 dwConv &= ~IME_CMODE_CHARCODE;
  51.             else
  52.                 dwConv |= IME_CMODE_CHARCODE;
  53.             break;
  54.         case IDM_HANJA:
  55.             if (dwConv & IME_CMODE_HANJACONVERT)
  56.                 dwConv &= ~IME_CMODE_HANJACONVERT;
  57.             else
  58.                 dwConv |= IME_CMODE_HANJACONVERT;
  59.             break;
  60.         case IDM_SOFTKBD:
  61.             if (dwConv & IME_CMODE_SOFTKBD)
  62.                 dwConv &= ~IME_CMODE_SOFTKBD;
  63.             else
  64.                 dwConv |= IME_CMODE_SOFTKBD;
  65.             break;
  66.         case IDM_EUDC:
  67.             if (dwConv & IME_CMODE_EUDC)
  68.                 dwConv &= ~IME_CMODE_EUDC;
  69.             else
  70.                 dwConv |= IME_CMODE_EUDC;
  71.             break;
  72.         case IDM_SYMBOL:
  73.             if (dwConv & IME_CMODE_SYMBOL)
  74.                 dwConv &= ~IME_CMODE_SYMBOL;
  75.             else
  76.                 dwConv |= IME_CMODE_SYMBOL;
  77.             break;
  78.     }
  79.     ImmSetConversionStatus(hIMC,dwConv,dwSent);
  80.     ImmReleaseContext(hWndCompStr,hIMC);
  81.     return 1L;
  82. }
  83. LRESULT HandleConvertCommand(HWND hWnd,WPARAM wParam,LPARAM lParam)
  84. {
  85.     HIMC hIMC = ImmGetContext(hWndCompStr);
  86.     DWORD dwSel;
  87.     DWORD dwSize;
  88.     LPCANDIDATELIST lpCL;
  89.     switch(wParam)
  90.     {
  91.         case IDM_CONVERT:
  92.             ImmNotifyIME(hIMC,NI_COMPOSITIONSTR,CPS_CONVERT,0);
  93.             break;
  94.         case IDM_CANCEL:
  95.             ImmNotifyIME(hIMC,NI_COMPOSITIONSTR,CPS_CANCEL,0);
  96.             break;
  97.         case IDM_REVERT:
  98.             ImmNotifyIME(hIMC,NI_COMPOSITIONSTR,CPS_REVERT,0);
  99.             break;
  100.         case IDM_COMPLETE:
  101.             ImmNotifyIME(hIMC,NI_COMPOSITIONSTR,CPS_COMPLETE,0);
  102.             break;
  103.         case IDM_OPENCAND:
  104.             ImmNotifyIME(hIMC,NI_OPENCANDIDATE,0,0);
  105.             break;
  106.         case IDM_CLOSECAND:
  107.             ImmNotifyIME(hIMC,NI_CLOSECANDIDATE,0,0);
  108.             break;
  109.         case IDM_NEXTCAND:
  110.         case IDM_PREVCAND:
  111.             if (dwSize = ImmGetCandidateList(hIMC,0x0,NULL,0))
  112.             {
  113.                 lpCL = (LPCANDIDATELIST)GlobalAlloc(GPTR,dwSize);
  114.         
  115.                 ImmGetCandidateList(hIMC,0x0,lpCL,dwSize);
  116.  
  117.                 dwSel = lpCL->dwSelection;
  118.                 if (wParam == IDM_NEXTCAND)
  119.                 {
  120.                    if (++dwSel >= lpCL->dwCount)
  121.                       dwSel = 0;
  122.                 }
  123.                 else
  124.                 {
  125.                    if (dwSel)
  126.                       dwSel--;
  127.                    else
  128.                       dwSel = lpCL->dwCount - 1;
  129.                 }
  130.                 GlobalFree((HANDLE)lpCL);
  131.                 ImmNotifyIME(hIMC,NI_SELECTCANDIDATESTR,0,dwSel);
  132.             }
  133.             break;
  134.     }
  135.     ImmReleaseContext(hWndCompStr,hIMC);
  136.     return 1;
  137. }