HZmodephtoch.c
资源名称:大熊猫输入法原码.zip [点击查看]
上传用户:szljw888
上传日期:2010-04-11
资源大小:124k
文件大小:3k
源码类别:
输入法编程
开发平台:
C/C++
- /*
- * Copyright (C) 1999.4 Li ZhenChun
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License; or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that is will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, M A 02139, USA.
- *
- * Author: Li ZhenChun email: zhchli@163.net or zhchli@126.com
- *
- */
- #include "freepy.h"
- BOOL CharHandlePhToCh( HIMC hIMC,WORD wParam,LONG lParam)
- {
- TCHAR YjmPressKey[2];
- YjmPressKey[0]=(char)wParam;
- YjmPressKey[1]=' ';
- //if( wParam >= _T('0') && wParam <= _T('9')|| ){//不断地分解
- if(_tcsstr(_T("0123456789;'/"),YjmPressKey)){
- LPINPUTCONTEXT lpIMC;
- LPCANDIDATEINFO lpCandInfo;
- LPCANDIDATELIST lpCandList;
- LPCOMPOSITIONSTRING lpCompStr;
- WORD wIdx,wCount;
- TCHAR szCharArr[50][4];
- LPTSTR lpNextChar,lpStr,lpConvStr;
- GENEMSG GnMsg;
- int i;
- lpIMC = ImmLockIMC(hIMC);
- lpCandInfo = (LPCANDIDATEINFO)ImmLockIMCC(lpIMC->hCandInfo);
- lpCandList = (LPCANDIDATELIST)((LPSTR)lpCandInfo + lpCandInfo->dwOffset[0]);
- lpCompStr = (LPCOMPOSITIONSTRING)ImmLockIMCC(lpIMC->hCompStr);
- if(wParam == (WORD)_T(';')) wIdx=1;
- else if(wParam == (WORD)_T(''')) wIdx=2;
- else if(wParam == (WORD)_T('/')) wIdx=2;
- else if( wParam == (WORD)_T('0') ) wIdx=9;
- else wIdx = wParam - _T('1');
- wIdx += (WORD)lpCandList->dwPageStart;
- if( wIdx >= 2 && wIdx < lpCandList->dwCount+2){
- wCount = 0;
- lpStr = GETLPCANDSTR(lpCandList,wIdx);
- lpNextChar = CharNext(lpStr);
- while( lpStr != lpNextChar ){
- memcpy(szCharArr[wCount],lpStr,lpNextChar-lpStr);
- szCharArr[wCount++][lpNextChar-lpStr] = _T(' ');
- lpStr = lpNextChar;
- lpNextChar = CharNext(lpStr);
- }
- if( !wCount ) goto my_exit;
- if( wCount == 1){
- lpConvStr = ((LPMYCOMPSTR)lpCompStr)->FreePYComp.szConvCompStr;
- _tcscpy(lpConvStr,szCharArr[0]);
- MakeResultString(hIMC,TRUE);
- wConversionMode =wPreConversionMode;
- goto my_exit;//最后的出口
- }
- if( wCount > CAND_PAGESIZE ) wCount = CAND_PAGESIZE;//10
- lpCandList->dwCount = wCount;//只输出CAND_PAGESIZE个汉字//10
- lpCandList->dwPageStart = 2;
- lpCandList->dwPageSize = CAND_PAGESIZE;//10;
- for (i=0;i<wCount;i++){
- _tcscpy(GETLPCANDSTR(lpCandList,i+2),szCharArr[i]);
- }
- GnMsg.msg = WM_IME_COMPOSITION;
- GnMsg.wParam = 0;
- GnMsg.lParam = GCS_COMPSTR;
- GenerateMessage(hIMC, lpdwCurTransKey,(LPGENEMSG)&GnMsg);
- }
- my_exit:
- ImmUnlockIMCC(lpIMC->hCandInfo);
- ImmUnlockIMCC(lpIMC->hCompStr);
- ImmUnlockIMC(hIMC);
- }
- return TRUE;
- }