HZmodewubi.c
资源名称:大熊猫输入法原码.zip [点击查看]
上传用户:szljw888
上传日期:2010-04-11
资源大小:124k
文件大小:44k
源码类别:
输入法编程
开发平台:
C/C++
- /* 大熊猫输入法(Free Chinese Input) 由YJMSIR(yjmsir@163.com)编写
- * 协议: GPL
- * freeinput( A Chinese Input Method) by YJMSIR(yjmsir@163.com)
- * Licence: GPL
- */
- #include "freepy.h"
- UINT ReturnHaveAutoCandList(LPTSTR,LPTSTR);
- UINT ReturnHaveAutoCandListErbi(LPTSTR,LPTSTR);
- BOOL CharHandleWuBiAttachLib( HIMC hIMC,WORD wParam,LONG lParam)
- {
- LPINPUTCONTEXT lpIMC;
- LPCANDIDATEINFO lpCandInfo;
- LPCANDIDATELIST lpCandList;
- LPCOMPOSITIONSTRING lpCompStr;
- GENEMSG GnMsg;
- LPTSTR lpStr,lpStr1;
- WORD wStrLen,i,k=2;
- TCHAR YjmPressKey[2];
- int ComXResult1,ComXResult2;
- WBRecord __based(lpWubiMapFileBase) *recTemp1;
- AttachLibRecord __based(lpAttachLibMapFileBase) *recTemp2;
- YjmPressKey[0]=(char)wParam;
- YjmPressKey[1]=' ';
- if(!(wConversionSet &CONVERSION_SET_USEWB)) return 1;
- if(!(wConversionSet &CONVERSION_SET_USEATTACH)) return 1;
- /* if((wConversionSet & CONVERSION_SET_WBSPEED) && (WuBiSpeed!=0))
- _stprintf(YJMMessage,"(%d字/分):",WuBiSpeed);
- else*/
- _tcscpy(YJMMessage,_T(""));
- lpIMC = ImmLockIMC(hIMC);
- lpCandInfo = (LPCANDIDATEINFO)ImmLockIMCC(lpIMC->hCandInfo);
- lpCandList = (LPCANDIDATELIST)((LPSTR)lpCandInfo + lpCandInfo->dwOffset[0]);
- lpCompStr = (LPCOMPOSITIONSTRING)ImmLockIMCC(lpIMC->hCompStr);
- lpCandList->dwPageSize=CAND_PAGESIZE;
- if(lpCandList->dwPageStart <2) lpCandList->dwPageStart = 2;
- lpStr = GETLPCOMPSTR(lpCompStr);
- wStrLen = _tcslen(lpStr);
- //接收键盘输入
- //if(wParam >= _T('a') && wParam <= _T('z')){
- if(_tcsstr(WbUsedcodes,YjmPressKey)||_tcsstr(AttUsedcodes,YjmPressKey)){
- wStrLen = _tcslen(lpStr);
- *(lpStr + wStrLen) = (TCHAR)wParam;
- *(lpStr + wStrLen +1) = _T(' ');
- lpCompStr->dwCompStrLen = wStrLen = _tcslen(lpStr);
- //对于极点z万能键的兼容
- if(wParam == _T('z')&&wStrLen==1){
- if(_tcslen(((LPMYCOMPSTR)lpCompStr)->FreePYComp.szPreResultStr)!=0){
- _tcscpy(GETLPCANDSTR(lpCandList,2),((LPMYCOMPSTR)lpCompStr)->FreePYComp.szPreResultStr);
- lpCandList->dwCount =1;
- wubiDictCurrent = wubiDictHead->next;
- goto yjmwubidisplay;
- }
- }
- //多于4键(即5键)的处理,适用于盲打,不浪费输入的字符
- if(!(wConversionSet & CONVERSION_SET_CODEGT4)){
- if(wStrLen>4){
- SpaceSelect(hIMC,wParam);
- szPreResultCode[wStrLen-1]=_T(' ');
- _tcscpy(lpStr,lpStr+wStrLen-1);
- lpCompStr->dwCompStrLen = wStrLen = _tcslen(lpStr);
- }
- }
- if(CodeForward && wStrLen>2&&
- AttachLibDictCurrent!=AttachLibDictHead->prev &&
- wubiDictCurrent!=wubiDictHead->prev ){
- ComXResult1=(int)CompareWBCodeX(lpStr,wubiDictCurrent->strCode);
- ComXResult1-=MaxCompareWBCodeX-(wStrLen-1);
- ComXResult2=(int)CompareWBCodeX(lpStr,AttachLibDictCurrent->strCode);
- ComXResult2-=MaxCompareWBCodeX-(wStrLen-1);
- if(ComXResult1>0 &&ComXResult2>0){
- SpaceSelect(hIMC,wParam);
- szPreResultCode[wStrLen-1]=_T(' ');
- _tcscpy(lpStr,lpStr+wStrLen-1);
- lpCompStr->dwCompStrLen = wStrLen = _tcslen(lpStr);
- }
- else if(ComXResult1==0 &&ComXResult2==0){
- if(_tcscmp(lpStr,AttachLibDictCurrent->strCode)<0 &&
- _tcscmp(lpStr,wubiDictCurrent->strCode)<0){
- SpaceSelect(hIMC,wParam);
- szPreResultCode[wStrLen-1]=_T(' ');
- _tcscpy(lpStr,lpStr+wStrLen-1);
- lpCompStr->dwCompStrLen = wStrLen = _tcslen(lpStr);
- }
- else if(_tcscmp(lpStr,AttachLibDictCurrent->strCode)>0&&
- _tcscmp(lpStr,wubiDictCurrent->strCode)>0){
- recTemp2=AttachLibDictCurrent;
- while(recTemp2->next!=AttachLibDictHead->prev&&
- _tcscmp(lpStr,recTemp2->strCode)>0)
- recTemp2=recTemp2->next;
- recTemp1=wubiDictCurrent;
- while(recTemp1->next!=wubiDictHead->prev&&
- _tcscmp(lpStr,recTemp1->strCode)>0)
- recTemp1=recTemp1->next;
- ComXResult1=(int)CompareWBCodeX(lpStr,recTemp1->strCode);
- ComXResult1-=MaxCompareWBCodeX-wStrLen;
- ComXResult2=(int)CompareWBCodeX(lpStr,recTemp2->strCode);
- ComXResult2-=MaxCompareWBCodeX-wStrLen;
- if(_tcscmp(lpStr,recTemp1->strCode)<0 && ComXResult1>0&&
- _tcscmp(lpStr,recTemp2->strCode)<0 && ComXResult2>0){
- SpaceSelect(hIMC,wParam);
- szPreResultCode[wStrLen-1]=_T(' ');
- _tcscpy(lpStr,lpStr+wStrLen-1);
- lpCompStr->dwCompStrLen = wStrLen = _tcslen(lpStr);
- }
- }
- }
- }
- CodeForward=1;
- //依编码查找五笔//加快速度的方案
- if(wStrLen<2)
- wubiDictCurrent = wubiDictHead->next;
- else wubiDictCurrent = wubiDictCurrentRecord;
- while (wubiDictCurrent != wubiDictHead->prev) {
- if (_tcscmp(lpStr, wubiDictCurrent->strCode)<=0) {
- if (_tcscmp(lpStr,wubiDictCurrent->strCode)<0) {
- lpCandList->dwCount=0;
- break;
- }
- wubiDictCurrentRecord=wubiDictCurrent;
- for( i=0,k=2;i<CAND_PAGESIZE;i++){
- if(wubiDictCurrent == wubiDictHead->prev) break;
- if(_tcscmp (lpStr, wubiDictCurrent->strCode)) break;
- if(!(wConversionSet & CONVERSION_SET_GBK) &&
- !IsStringGb2312(wubiDictCurrent->strHZ)) {
- wubiDictCurrent = wubiDictCurrent->next;
- continue;
- }
- //取消对非gb2312字的上屏
- _tcscpy(GETLPCANDSTR(lpCandList,k),wubiDictCurrent->strHZ);
- k++;
- wubiDictCurrent = wubiDictCurrent->next;
- }
- lpCandList->dwCount =k-2;
- break;
- }
- wubiDictCurrent = wubiDictCurrent->next;
- }
- //依编码查找附加词库//加快速度的方案
- if(wStrLen<2)
- AttachLibDictCurrent = AttachLibDictHead->next;
- else AttachLibDictCurrent = AttachLibDictCurrentRecord;
- while (AttachLibDictCurrent != AttachLibDictHead->prev) {
- if (_tcscmp(lpStr, AttachLibDictCurrent->strCode)<=0) {
- AttachLibDictCurrentRecord=AttachLibDictCurrent;
- for(i=0;i<CAND_PAGESIZE && k<CAND_PAGESIZE+2;i++){//
- if(AttachLibDictCurrent == AttachLibDictHead->prev) break;
- if(_tcscmp (lpStr, AttachLibDictCurrent->strCode)) break;
- //仅gb2312字符集汉字上屏
- if(!(wConversionSet & CONVERSION_SET_GBK) &&
- !IsStringGb2312(AttachLibDictCurrent->strHZ)) {
- AttachLibDictCurrent = AttachLibDictCurrent->next;
- continue;
- }
- _tcscpy(GETLPCANDSTR(lpCandList,k),AttachLibDictCurrent->strHZ);
- k++;
- AttachLibDictCurrent = AttachLibDictCurrent->next;
- }
- lpCandList->dwCount =k-2;
- break;
- }
- AttachLibDictCurrent = AttachLibDictCurrent->next;
- }
- //
- if(wStrLen>2&&(lpCandList->dwCount ==1)&&
- AttachLibDictCurrent!=AttachLibDictHead->prev&&
- wubiDictCurrent!=wubiDictHead->prev){
- ComXResult1=(int)CompareWBCodeX(lpStr,wubiDictCurrent->strCode);
- ComXResult1-=MaxCompareWBCodeX-(wStrLen-1);
- ComXResult2=(int)CompareWBCodeX(lpStr,AttachLibDictCurrent->strCode);
- ComXResult2-=MaxCompareWBCodeX-(wStrLen-1);
- if(ComXResult1>0&&ComXResult2>0){
- SpaceSelect(hIMC,wParam);
- goto yjmwubidisplay;
- }
- }
- }
- //以上接收键盘输入a-z
- //翻页功能
- else if( wParam == _T('=') || wParam == _T('>')) {//wParam == _T('.') ||
- //SelectForwardFromCand(hIMC,lpCandList);
- wubiDictCurrentRecord=wubiDictCurrent;
- AttachLibDictCurrentRecord=AttachLibDictCurrent;
- wParam=*(lpStr+wStrLen-1);
- *(lpStr+wStrLen-1)=_T(' ');
- CodeForward=0;
- ImmUnlockIMCC(lpIMC->hCompStr);
- ImmUnlockIMC(hIMC);
- CharHandleWuBiAttachLib(hIMC,wParam,0);
- }
- else if( wParam == _T('-') || wParam == _T('<')) {//wParam == _T(',') ||
- //SelectBackwardFromCand(hIMC,lpCandList);
- UINT i;
- for(i=0;i<CAND_PAGESIZE && wubiDictCurrentRecord!=wubiDictHead->next;i++){
- wubiDictCurrentRecord=wubiDictCurrentRecord->prev;
- }
- for(i=0;i<CAND_PAGESIZE && AttachLibDictCurrentRecord!=AttachLibDictHead->next;i++){
- AttachLibDictCurrentRecord=AttachLibDictCurrentRecord->prev;
- }
- wParam=*(lpStr+wStrLen-1);
- *(lpStr+wStrLen-1)=_T(' ');
- CodeForward=0;
- ImmUnlockIMCC(lpIMC->hCompStr);
- ImmUnlockIMC(hIMC);
- CharHandleWuBiAttachLib(hIMC,wParam,0);
- }
- //选择功能1234567890
- else if( wParam >= _T('0') && wParam <= _T('9') ){
- if( !IsCompStr(hIMC)) return FALSE;//如果首键是数字,放行。
- SelectCandFromCandlist(hIMC, wParam);
- }
- //选用第二候选词的方便键
- else if( wParam == _T(';')&&lpCandList->dwCount >=2){
- SelectCandFromCandlist(hIMC, _T('2'));
- }
- //选用第三候选词的方便键
- else if( wParam == _T(''')&&lpCandList->dwCount >=3){
- SelectCandFromCandlist(hIMC, _T('3'));
- }
- //符号推字上屏
- else if( wParam == _T('!')||wParam == _T('@')||wParam == _T('#')||wParam == _T('$')||
- wParam == _T('%')||wParam == _T('^')||wParam == _T('&')||wParam == _T('*')||
- wParam == _T('(')||wParam == _T(')')||wParam == _T(',')||wParam == _T('.')||
- wParam == _T(';')||wParam == _T(''')||wParam == _T('\')||wParam == _T('/')||
- wParam == _T(':')||wParam == _T('"')||wParam == _T('?')||
- wParam == _T('[')||wParam == _T(']')||wParam == _T('{')||wParam == _T('}')){
- PunctPushWordFlag=1;
- SelectCandFromCandlist( hIMC, _T('1'));
- PunctPushWordFlag=0;
- GeneratePunct(hIMC,wParam);
- return TRUE;
- }
- else return FALSE;
- //显示
- yjmwubidisplay:
- lpStr1 = ((LPMYCOMPSTR)lpCompStr)->FreePYComp.szPaintCompStr;
- _tcscpy(lpStr1,lpStr);
- ((LPMYCOMPSTR)lpCompStr)->FreePYComp.wEditCaret=_tcslen(lpStr1);
- if(wConversionSet & CONVERSION_SET_WBSPEED) _tcscat(lpStr1,SpeedMessage);//显示提示
- GnMsg.msg = WM_IME_COMPOSITION;
- GnMsg.wParam = 0;
- GnMsg.lParam = GCS_COMPSTR;
- GenerateMessage(hIMC, lpdwCurTransKey,(LPGENEMSG)&GnMsg);
- //yjmwubiexit:
- ImmUnlockIMCC(lpIMC->hCompStr);
- ImmUnlockIMCC(lpIMC->hCandInfo);
- ImmUnlockIMC(hIMC);
- return TRUE;
- }
- /*
- BOOL CharHandleWuBiAttachLib( HIMC hIMC,WORD wParam,LONG lParam)
- {
- LPINPUTCONTEXT lpIMC;
- LPCANDIDATEINFO lpCandInfo;
- LPCANDIDATELIST lpCandList;
- LPCOMPOSITIONSTRING lpCompStr;
- GENEMSG GnMsg;
- LPTSTR lpStr,lpStr1;
- WORD wStrLen,i,k=2;
- TCHAR YjmPressKey[2];
- int ComXResult1,ComXResult2;
- WBRecord __based(lpWubiMapFileBase) *recTemp1;
- AttachLibRecord __based(lpAttachLibMapFileBase) *recTemp2;
- YjmPressKey[0]=(char)wParam;
- YjmPressKey[1]=' ';
- if(!(wConversionSet &CONVERSION_SET_USEWB)) return 1;
- if(!(wConversionSet &CONVERSION_SET_USEATTACH)) return 1;
- /* if((wConversionSet & CONVERSION_SET_WBSPEED) && (WuBiSpeed!=0))
- _stprintf(YJMMessage,"(%d字/分):",WuBiSpeed);
- else
- _tcscpy(YJMMessage,_T(""));/
- lpIMC = ImmLockIMC(hIMC);
- lpCandInfo = (LPCANDIDATEINFO)ImmLockIMCC(lpIMC->hCandInfo);
- lpCandList = (LPCANDIDATELIST)((LPSTR)lpCandInfo + lpCandInfo->dwOffset[0]);
- lpCompStr = (LPCOMPOSITIONSTRING)ImmLockIMCC(lpIMC->hCompStr);
- lpCandList->dwPageSize=CAND_PAGESIZE;
- if(lpCandList->dwPageStart <2) lpCandList->dwPageStart = 2;
- lpStr = GETLPCOMPSTR(lpCompStr);
- wStrLen = _tcslen(lpStr);
- //接收键盘输入
- //if(wParam >= _T('a') && wParam <= _T('z')){
- if(_tcsstr(WbUsedcodes,YjmPressKey)||_tcsstr(AttUsedcodes,YjmPressKey)){
- wStrLen = _tcslen(lpStr);
- *(lpStr + wStrLen) = (TCHAR)wParam;
- *(lpStr + wStrLen +1) = _T(' ');
- lpCompStr->dwCompStrLen = wStrLen = _tcslen(lpStr);
- //对于极点z万能键的兼容
- if(wParam == _T('z')&&wStrLen==1){
- if(_tcslen(((LPMYCOMPSTR)lpCompStr)->FreePYComp.szPreResultStr)!=0){
- _tcscpy(GETLPCANDSTR(lpCandList,2),((LPMYCOMPSTR)lpCompStr)->FreePYComp.szPreResultStr);
- lpCandList->dwCount =1;
- wubiDictCurrent = wubiDictHead->next;
- goto yjmwubidisplay;
- }
- }
- //多于4键(即5键)的处理,适用于盲打,不浪费输入的字符
- if(!(wConversionSet & CONVERSION_SET_CODEGT4)){
- if(wStrLen>4){
- SpaceSelect(hIMC,wParam);
- szPreResultCode[wStrLen-1]=_T(' ');
- _tcscpy(lpStr,lpStr+wStrLen-1);
- lpCompStr->dwCompStrLen = wStrLen = _tcslen(lpStr);
- }
- }
- if(CodeForward && wStrLen>2&&
- AttachLibDictCurrent!=AttachLibDictHead->prev &&
- wubiDictCurrent!=wubiDictHead->prev ){
- ComXResult1=(int)CompareWBCodeX(lpStr,wubiDictCurrent->strCode);
- ComXResult1-=MaxCompareWBCodeX-(wStrLen-1);
- ComXResult2=(int)CompareWBCodeX(lpStr,AttachLibDictCurrent->strCode);
- ComXResult2-=MaxCompareWBCodeX-(wStrLen-1);
- if(ComXResult1>0 &&ComXResult2>0){
- SpaceSelect(hIMC,wParam);
- szPreResultCode[wStrLen-1]=_T(' ');
- _tcscpy(lpStr,lpStr+wStrLen-1);
- lpCompStr->dwCompStrLen = wStrLen = _tcslen(lpStr);
- }
- else if(ComXResult1==0 &&ComXResult2==0){
- if(_tcscmp(lpStr,AttachLibDictCurrent->strCode)<0 &&
- _tcscmp(lpStr,wubiDictCurrent->strCode)<0){
- SpaceSelect(hIMC,wParam);
- szPreResultCode[wStrLen-1]=_T(' ');
- _tcscpy(lpStr,lpStr+wStrLen-1);
- lpCompStr->dwCompStrLen = wStrLen = _tcslen(lpStr);
- }
- else if(_tcscmp(lpStr,AttachLibDictCurrent->strCode)>0&&
- _tcscmp(lpStr,wubiDictCurrent->strCode)>0){
- recTemp2=AttachLibDictCurrent;
- while(recTemp2->next!=AttachLibDictHead->prev&&
- _tcscmp(lpStr,recTemp2->strCode)>0)
- recTemp2=recTemp2->next;
- recTemp1=wubiDictCurrent;
- while(recTemp1->next!=wubiDictHead->prev&&
- _tcscmp(lpStr,recTemp1->strCode)>0)
- recTemp1=recTemp1->next;
- ComXResult1=(int)CompareWBCodeX(lpStr,recTemp1->strCode);
- ComXResult1-=MaxCompareWBCodeX-wStrLen;
- ComXResult2=(int)CompareWBCodeX(lpStr,recTemp2->strCode);
- ComXResult2-=MaxCompareWBCodeX-wStrLen;
- if(_tcscmp(lpStr,recTemp1->strCode)<0 && ComXResult1>0&&
- _tcscmp(lpStr,recTemp2->strCode)<0 && ComXResult2>0){
- SpaceSelect(hIMC,wParam);
- szPreResultCode[wStrLen-1]=_T(' ');
- _tcscpy(lpStr,lpStr+wStrLen-1);
- lpCompStr->dwCompStrLen = wStrLen = _tcslen(lpStr);
- }
- }
- }
- }
- CodeForward=1;
- //依编码查找五笔//加快速度的方案
- if(wStrLen<2)
- wubiDictCurrent = wubiDictHead->next;
- else wubiDictCurrent = wubiDictCurrentRecord;
- while (wubiDictCurrent != wubiDictHead->prev) {
- if (_tcscmp(lpStr, wubiDictCurrent->strCode)<=0) {
- if (_tcscmp(lpStr,wubiDictCurrent->strCode)<0) {
- lpCandList->dwCount=0;
- break;
- }
- wubiDictCurrentRecord=wubiDictCurrent;
- //for( i=0,k=2;i<MAXCANDSTRNUM;i++){
- if(wubiDictCurrent == wubiDictHead->prev) break;
- if(_tcscmp (lpStr, wubiDictCurrent->strCode)) break;
- if(!(wConversionSet & CONVERSION_SET_GBK) &&
- !IsStringGb2312(wubiDictCurrent->strHZ)) {
- wubiDictCurrent = wubiDictCurrent->next;
- continue;
- }
- //取消对非gb2312字的上屏
- _tcscpy(GETLPCANDSTR(lpCandList,k),wubiDictCurrent->strHZ);
- k++;
- wubiDictCurrent = wubiDictCurrent->next;
- }
- lpCandList->dwCount =k-2;
- break;
- }
- wubiDictCurrent = wubiDictCurrent->next;
- }
- //依编码查找附加词库//加快速度的方案
- if(wStrLen<2)
- AttachLibDictCurrent = AttachLibDictHead->next;
- else AttachLibDictCurrent = AttachLibDictCurrentRecord;
- while (AttachLibDictCurrent != AttachLibDictHead->prev) {
- if (_tcscmp(lpStr, AttachLibDictCurrent->strCode)<=0) {
- AttachLibDictCurrentRecord=AttachLibDictCurrent;
- //for( i=0;i<MAXCANDSTRNUM;i++){
- if(AttachLibDictCurrent == AttachLibDictHead->prev) break;
- if(_tcscmp (lpStr, AttachLibDictCurrent->strCode)) break;
- //仅gb2312字符集汉字上屏
- if(!(wConversionSet & CONVERSION_SET_GBK) &&
- !IsStringGb2312(AttachLibDictCurrent->strHZ)) {
- AttachLibDictCurrent = AttachLibDictCurrent->next;
- continue;
- }
- _tcscpy(GETLPCANDSTR(lpCandList,k),AttachLibDictCurrent->strHZ);
- k++;
- AttachLibDictCurrent = AttachLibDictCurrent->next;
- }
- lpCandList->dwCount =k-2;
- break;
- }
- AttachLibDictCurrent = AttachLibDictCurrent->next;
- }
- if(wStrLen>2&&(lpCandList->dwCount ==1)&&
- AttachLibDictCurrent!=AttachLibDictHead->prev&&
- wubiDictCurrent!=wubiDictHead->prev){
- ComXResult1=(int)CompareWBCodeX(lpStr,wubiDictCurrent->strCode);
- ComXResult1-=MaxCompareWBCodeX-(wStrLen-1);
- ComXResult2=(int)CompareWBCodeX(lpStr,AttachLibDictCurrent->strCode);
- ComXResult2-=MaxCompareWBCodeX-(wStrLen-1);
- if(ComXResult1>0&&ComXResult2>0){
- SpaceSelect(hIMC,wParam);
- goto yjmwubidisplay;
- }
- }
- }
- //以上接收键盘输入a-z
- //翻页功能
- else if( wParam == _T('=') || wParam == _T('>')) {//wParam == _T('.') ||
- SelectForwardFromCand(hIMC,lpCandList);
- }
- else if( wParam == _T('-') || wParam == _T('<')) {//wParam == _T(',') ||
- SelectBackwardFromCand(hIMC,lpCandList);
- }
- //选择功能1234567890
- else if( wParam >= _T('0') && wParam <= _T('9') ){
- if( !IsCompStr(hIMC)) return FALSE;//如果首键是数字,放行。
- SelectCandFromCandlist(hIMC, wParam);
- }
- //选用第二候选词的方便键
- else if( wParam == _T(';')&&lpCandList->dwCount >=2){
- SelectCandFromCandlist(hIMC, _T('2'));
- }
- //选用第三候选词的方便键
- else if( wParam == _T(''')&&lpCandList->dwCount >=3){
- SelectCandFromCandlist(hIMC, _T('3'));
- }
- //符号推字上屏
- else if( wParam == _T('!')||wParam == _T('@')||wParam == _T('#')||wParam == _T('$')||
- wParam == _T('%')||wParam == _T('^')||wParam == _T('&')||wParam == _T('*')||
- wParam == _T('(')||wParam == _T(')')||wParam == _T(',')||wParam == _T('.')||
- wParam == _T(';')||wParam == _T(''')||wParam == _T('\')||wParam == _T('/')||
- wParam == _T(':')||wParam == _T('"')||wParam == _T('?')||
- wParam == _T('[')||wParam == _T(']')||wParam == _T('{')||wParam == _T('}')){
- PunctPushWordFlag=1;
- SelectCandFromCandlist( hIMC, _T('1'));
- PunctPushWordFlag=0;
- GeneratePunct(hIMC,wParam);
- return TRUE;
- }
- else return FALSE;
- //显示
- yjmwubidisplay:
- lpStr1 = ((LPMYCOMPSTR)lpCompStr)->FreePYComp.szPaintCompStr;
- _tcscpy(lpStr1,lpStr);
- ((LPMYCOMPSTR)lpCompStr)->FreePYComp.wEditCaret=_tcslen(lpStr1);
- if(wConversionSet & CONVERSION_SET_WBSPEED) _tcscat(lpStr1,SpeedMessage);//显示提示
- GnMsg.msg = WM_IME_COMPOSITION;
- GnMsg.wParam = 0;
- GnMsg.lParam = GCS_COMPSTR;
- GenerateMessage(hIMC, lpdwCurTransKey,(LPGENEMSG)&GnMsg);
- //yjmwubiexit:
- ImmUnlockIMCC(lpIMC->hCompStr);
- ImmUnlockIMCC(lpIMC->hCandInfo);
- ImmUnlockIMC(hIMC);
- return TRUE;
- }*/
- /*
- BOOL CharHandleWuBi( HIMC hIMC,WORD wParam,LONG lParam)
- {
- LPINPUTCONTEXT lpIMC;
- LPCANDIDATEINFO lpCandInfo;
- LPCANDIDATELIST lpCandList;
- LPCOMPOSITIONSTRING lpCompStr;
- GENEMSG GnMsg;
- LPTSTR lpStr,lpStr1;
- WORD wStrLen,i,k;
- TCHAR YjmPressKey[2];
- int ComXResult;
- WBRecord __based(lpWubiMapFileBase) *recTemp;
- YjmPressKey[0]=(char)wParam;
- YjmPressKey[1]=' ';
- if(!(wConversionSet &CONVERSION_SET_USEWB)) return 1;
- /*if((wConversionSet & CONVERSION_SET_WBSPEED) && (WuBiSpeed!=0))
- _stprintf(YJMMessage,"(%d字/分):",WuBiSpeed);
- else/
- _tcscpy(YJMMessage,_T(""));
- lpIMC = ImmLockIMC(hIMC);
- lpCandInfo = (LPCANDIDATEINFO)ImmLockIMCC(lpIMC->hCandInfo);
- lpCandList = (LPCANDIDATELIST)((LPSTR)lpCandInfo + lpCandInfo->dwOffset[0]);
- lpCompStr = (LPCOMPOSITIONSTRING)ImmLockIMCC(lpIMC->hCompStr);
- lpCandList->dwPageSize=CAND_PAGESIZE;
- if(lpCandList->dwPageStart <2) lpCandList->dwPageStart = 2;
- lpStr = GETLPCOMPSTR(lpCompStr);
- wStrLen = _tcslen(lpStr);
- //接收键盘输入
- //if(wParam >= _T('a') && wParam <= _T('z')){
- if(_tcsstr(WbUsedcodes,YjmPressKey)){
- wStrLen = _tcslen(lpStr);
- *(lpStr + wStrLen) = (TCHAR)wParam;
- *(lpStr + wStrLen +1) = _T(' ');
- lpCompStr->dwCompStrLen = wStrLen = _tcslen(lpStr);
- //对自然码,二笔的符号的支持
- //if(wConversionSet1 & C_SET1_ERBIMAKEWORD && wStrLen==1 && (wParam == _T(',')||wParam == _T('/')||wParam == _T(';')||wParam == _T('''))){//||wParam == _T(';')
- // GeneratePunct(hIMC,wParam);
- // return TRUE;
- //}
- //对极点z万能键的兼容
- if(wParam == _T('z')&&wStrLen==1){
- if(_tcslen(((LPMYCOMPSTR)lpCompStr)->FreePYComp.szPreResultStr)!=0){
- _tcscpy(GETLPCANDSTR(lpCandList,2),((LPMYCOMPSTR)lpCompStr)->FreePYComp.szPreResultStr);
- lpCandList->dwCount =1;
- wubiDictCurrent = wubiDictHead->next;
- goto yjmwubidisplay;
- }
- }
- //多于4键(即5键)的处理,适用于盲打,不浪费输入的字符
- if(!(wConversionSet & CONVERSION_SET_CODEGT4)&&
- (wConversionSet1 & C_SET1_AUTO_INPUT)){
- if(wStrLen>4){
- SpaceSelect(hIMC,wParam);
- szPreResultCode[wStrLen-1]=_T(' ');
- _tcscpy(lpStr,lpStr+wStrLen-1);
- lpCompStr->dwCompStrLen = wStrLen = _tcslen(lpStr);
- }
- }
- //查找最后输入的MAXAUTOWUBINUM/2个汉字中是否与输入的编码相同
- //如果已经输入了四个编码并且许可全自动造词提示
- if(wStrLen==4 && (wConversionSet & CONVERSION_SET_AUTOWORD)){
- if(wConversionSet1 & C_SET1_ERBIMAKEWORD)
- HaveAutoCandList=ReturnHaveAutoCandListErbi(lpStr,_T(""));
- else
- HaveAutoCandList=ReturnHaveAutoCandList(lpStr,_T(""));
- }
- else
- HaveAutoCandList=0;
- //非前缀化解决方法
- ComXResult=(int)CompareWBCodeX(lpStr,wubiDictCurrent->strCode);
- ComXResult-=MaxCompareWBCodeX-(wStrLen-1);
- if(!HaveAutoCandList && wStrLen>3 &&
- CodeForward &&wubiDictCurrent!=wubiDictHead->prev &&
- (wConversionSet1 & C_SET1_AUTO_INPUT)){
- if(ComXResult>0){
- SpaceSelect(hIMC,wParam);
- szPreResultCode[wStrLen-1]=_T(' ');
- _tcscpy(lpStr,lpStr+wStrLen-1);
- lpCompStr->dwCompStrLen = wStrLen = _tcslen(lpStr);
- }
- else if(ComXResult==0){
- if(_tcscmp(lpStr,wubiDictCurrent->strCode)<0){
- SpaceSelect(hIMC,wParam);
- szPreResultCode[wStrLen-1]=_T(' ');
- _tcscpy(lpStr,lpStr+wStrLen-1);
- lpCompStr->dwCompStrLen = wStrLen = _tcslen(lpStr);
- }
- else if(_tcscmp(lpStr,wubiDictCurrent->strCode)>0){
- recTemp=wubiDictCurrent;
- while(recTemp->next!=wubiDictHead->prev&&
- _tcscmp(lpStr,recTemp->strCode)>0)
- recTemp=recTemp->next;
- ComXResult=(int)CompareWBCodeX(lpStr,recTemp->strCode);
- ComXResult-=MaxCompareWBCodeX-wStrLen;
- if(_tcscmp(lpStr,recTemp->strCode)<0 && ComXResult>0){
- SpaceSelect(hIMC,wParam);
- szPreResultCode[wStrLen-1]=_T(' ');
- _tcscpy(lpStr,lpStr+wStrLen-1);
- lpCompStr->dwCompStrLen = wStrLen = _tcslen(lpStr);
- }
- }
- }
- }
- CodeForward=1;
- //依编码查找五笔//加快速度的方案
- if(wStrLen<2)
- wubiDictCurrent = wubiDictHead->next;
- else wubiDictCurrent = wubiDictCurrentRecord;
- while (wubiDictCurrent != wubiDictHead->prev) {
- if (_tcscmp(lpStr, wubiDictCurrent->strCode)<=0) {
- if (_tcscmp(lpStr,wubiDictCurrent->strCode)<0) {
- lpCandList->dwCount=0;
- break;
- }
- wubiDictCurrentRecord=wubiDictCurrent;
- //for( i=0,k=2;i<MAXCANDSTRNUM;i++){
- if(wubiDictCurrent == wubiDictHead->prev) break;
- if(_tcscmp (lpStr, wubiDictCurrent->strCode)) break;
- if(!(wConversionSet & CONVERSION_SET_GBK) &&
- !IsStringGb2312(wubiDictCurrent->strHZ)) {
- wubiDictCurrent = wubiDictCurrent->next;
- continue;
- }
- //取消对非gb2312字的上屏
- _tcscpy(GETLPCANDSTR(lpCandList,k),wubiDictCurrent->strHZ);
- k++;
- wubiDictCurrent = wubiDictCurrent->next;
- }
- lpCandList->dwCount =k-2;
- break;
- }
- wubiDictCurrent = wubiDictCurrent->next;
- }
- //如果自动加词找到与输入编码相同词组,则添加于最后。//如果自动词与最后一项相同,不显示
- if(HaveAutoCandList){
- k=0;//重复利用k作为标志
- for(i=0;i<lpCandList->dwCount;i++){
- if(!strcmp(AutoWuBiWord,GETLPCANDSTR(lpCandList,2+i))){//如果与某个已有的选项相同
- k=1;
- if((wConversionSet1 & C_SET1_ERBIMAKEWORD)?
- !ReturnHaveAutoCandListErbi(lpStr,GETLPCANDSTR(lpCandList,2+i)):
- !ReturnHaveAutoCandList(lpStr,GETLPCANDSTR(lpCandList,2+i))){//二次造词
- HaveAutoCandList=0;
- goto NoAddAutoMakeWord;//如果二次造词失败
- }
- }
- }
- if(k==1){
- for(i=0;i<lpCandList->dwCount;i++){
- if(!strcmp(AutoWuBiWord,GETLPCANDSTR(lpCandList,2+i))){
- HaveAutoCandList=0;
- goto NoAddAutoMakeWord;//二次清除
- }
- }
- }
- _tcscpy(YJMMessage,_T("(末项造词:)"));//提示
- _tcscpy(GETLPCANDSTR(lpCandList,2+lpCandList->dwCount),AutoWuBiWord);
- lpCandList->dwCount +=1;
- }
- NoAddAutoMakeWord:
- CodeHintTextBegin=lpCandList->dwCount;
- if(wConversionSet1 & C_SET1_CODE_HINT){
- for(i=0;i<lpCandList->dwCount;i++)
- _tcscpy(CodeHintText[i],"");
- recTemp=wubiDictCurrent;
- while(lpCandList->dwCount<CAND_PAGESIZE){
- _tcscpy(GETLPCANDSTR(lpCandList,2+lpCandList->dwCount),recTemp->strHZ);
- _tcscpy(CodeHintText[lpCandList->dwCount],recTemp->strCode);
- recTemp = recTemp->next;
- lpCandList->dwCount +=1;
- }
- }
- ComXResult=(int)CompareWBCodeX(lpStr,wubiDictCurrent->strCode);
- ComXResult-=MaxCompareWBCodeX-wStrLen;
- if(!HaveAutoCandList && wStrLen>2&&
- wubiDictCurrent!=wubiDictHead->prev){
- if((lpCandList->dwCount ==1)&&
- ComXResult>0 &&
- (wConversionSet1 & C_SET1_AUTO_INPUT)){//单个选项自动上屏
- SpaceSelect(hIMC,wParam);
- goto yjmwubidisplay;
- }
- }
- }
- //以上接收键盘输入a-z
- //翻页功能
- else if( wParam == _T('=') || wParam == _T('>')) {//wParam == _T('.') ||
- SelectForwardFromCand(hIMC,lpCandList);
- }
- else if( wParam == _T('-') || wParam == _T('<')) {//wParam == _T(',') ||
- SelectBackwardFromCand(hIMC,lpCandList);
- }
- //选择功能1234567890
- else if( wParam >= _T('0') && wParam <= _T('9') ){
- if( !IsCompStr(hIMC)) return FALSE;//如果首键是数字,放行。
- SelectCandFromCandlist(hIMC, wParam);
- }
- //选用第二候选词的方便键
- else if( wParam == _T(';')&&lpCandList->dwCount >=2){
- SelectCandFromCandlist(hIMC, _T('2'));
- }
- //选用第三候选词的方便键
- else if( wParam == _T(''')&&lpCandList->dwCount >=3){
- SelectCandFromCandlist(hIMC, _T('3'));
- }
- //符号推字上屏
- else if( wParam == _T('!')||wParam == _T('@')||wParam == _T('#')||wParam == _T('$')||
- wParam == _T('%')||wParam == _T('^')||wParam == _T('&')||wParam == _T('*')||
- wParam == _T('(')||wParam == _T(')')||wParam == _T(',')||wParam == _T('.')||
- wParam == _T(';')||wParam == _T(''')||wParam == _T('\')||wParam == _T('/')||
- wParam == _T(':')||wParam == _T('"')||wParam == _T('?')||
- wParam == _T('[')||wParam == _T(']')||wParam == _T('{')||wParam == _T('}')){
- //if(wConversionSet1 & C_SET1_AUTO_INPUT){
- PunctPushWordFlag=1;
- SelectCandFromCandlist( hIMC, _T('1'));
- PunctPushWordFlag=0;
- GeneratePunct(hIMC,wParam);
- return TRUE;
- /*}
- else {
- PunctPushWordFlag=1;
- wPreConversionMode=wConversionMode;
- fTempState=1;
- wConversionMode=CONVERSION_MODE_ENGLISH;
- //SelectCandFromCandlist( hIMC, _T('1'));
- MakeResultString(hIMC,TRUE);
- PunctPushWordFlag=0;
- GeneratePunct(hIMC,wParam);
- return TRUE;
- }/
- }
- else {
- ImmUnlockIMCC(lpIMC->hCompStr);
- ImmUnlockIMCC(lpIMC->hCandInfo);
- ImmUnlockIMC(hIMC);
- return FALSE;
- }
- //显示
- yjmwubidisplay:
- lpStr1 = ((LPMYCOMPSTR)lpCompStr)->FreePYComp.szPaintCompStr;
- _tcscpy(lpStr1,lpStr);
- ((LPMYCOMPSTR)lpCompStr)->FreePYComp.wEditCaret=_tcslen(lpStr1);
- if(wConversionSet & CONVERSION_SET_WBSPEED) _tcscat(lpStr1,SpeedMessage);//显示提示YJMMessage
- _tcscat(lpStr1,YJMMessage);
- GnMsg.msg = WM_IME_COMPOSITION;
- GnMsg.wParam = 0;
- GnMsg.lParam = GCS_COMPSTR;
- GenerateMessage(hIMC, lpdwCurTransKey,(LPGENEMSG)&GnMsg);
- //yjmwubiexit:
- ImmUnlockIMCC(lpIMC->hCompStr);
- ImmUnlockIMCC(lpIMC->hCandInfo);
- ImmUnlockIMC(hIMC);
- return TRUE;
- }*/
- //
- BOOL CharHandleWuBi( HIMC hIMC,WORD wParam,LONG lParam)
- {
- LPINPUTCONTEXT lpIMC;
- LPCANDIDATEINFO lpCandInfo;
- LPCANDIDATELIST lpCandList;
- LPCOMPOSITIONSTRING lpCompStr;
- GENEMSG GnMsg;
- LPTSTR lpStr,lpStr1;
- WORD wStrLen,i,k;
- TCHAR YjmPressKey[2];
- int ComXResult;
- WBRecord __based(lpWubiMapFileBase) *recTemp;
- YjmPressKey[0]=(char)wParam;
- YjmPressKey[1]=' ';
- if(!(wConversionSet &CONVERSION_SET_USEWB)) return 1;
- _tcscpy(YJMMessage,_T(""));
- lpIMC = ImmLockIMC(hIMC);
- lpCandInfo = (LPCANDIDATEINFO)ImmLockIMCC(lpIMC->hCandInfo);
- lpCandList = (LPCANDIDATELIST)((LPSTR)lpCandInfo + lpCandInfo->dwOffset[0]);
- lpCompStr = (LPCOMPOSITIONSTRING)ImmLockIMCC(lpIMC->hCompStr);
- lpCandList->dwPageSize=CAND_PAGESIZE;
- if(lpCandList->dwPageStart <2) lpCandList->dwPageStart = 2;
- lpStr = GETLPCOMPSTR(lpCompStr);
- wStrLen = _tcslen(lpStr);
- //接收键盘输入
- if(_tcsstr(WbUsedcodes,YjmPressKey)){
- wStrLen = _tcslen(lpStr);
- *(lpStr + wStrLen) = (TCHAR)wParam;
- *(lpStr + wStrLen +1) = _T(' ');
- lpCompStr->dwCompStrLen = wStrLen = _tcslen(lpStr);
- //对极点z万能键的兼容
- if(wParam == _T('z')&&wStrLen==1){
- if(_tcslen(((LPMYCOMPSTR)lpCompStr)->FreePYComp.szPreResultStr)!=0){
- _tcscpy(GETLPCANDSTR(lpCandList,2),((LPMYCOMPSTR)lpCompStr)->FreePYComp.szPreResultStr);
- lpCandList->dwCount =1;
- //wubiDictCurrent = wubiDictHead->next;
- //{
- SetwubiFirstLeadChr((TCHAR)wParam);
- wubiDictCurrentRecord=wubiFirstLeadChr[(TCHAR)wParam-_T('!')];
- //}
- goto yjmwubidisplay;
- }
- }
- //多于4键(即5键)的处理,适用于盲打,不浪费输入的字符
- if(!(wConversionSet & CONVERSION_SET_CODEGT4)&&
- (wConversionSet1 & C_SET1_AUTO_INPUT)){
- if(wStrLen>4){
- SpaceSelect(hIMC,wParam);
- szPreResultCode[wStrLen-1]=_T(' ');
- _tcscpy(lpStr,lpStr+wStrLen-1);
- lpCompStr->dwCompStrLen = wStrLen = _tcslen(lpStr);
- }
- }
- //查找最后输入的MAXAUTOWUBINUM/2个汉字中是否与输入的编码相同
- //如果已经输入了四个编码并且许可全自动造词提示
- if(wStrLen==4 && (wConversionSet & CONVERSION_SET_AUTOWORD)){
- if(wConversionSet1 & C_SET1_ERBIMAKEWORD)
- HaveAutoCandList=ReturnHaveAutoCandListErbi(lpStr,_T(""));
- else
- HaveAutoCandList=ReturnHaveAutoCandList(lpStr,_T(""));
- }
- else
- HaveAutoCandList=0;
- //非前缀化解决方法
- ComXResult=(int)CompareWBCodeX(lpStr,wubiDictCurrent->strCode);
- ComXResult-=MaxCompareWBCodeX-(wStrLen-1);
- if(!HaveAutoCandList && wStrLen>3 &&
- CodeForward && wubiDictCurrent!=wubiDictHead->prev &&
- (wConversionSet1 & C_SET1_AUTO_INPUT)){
- if(ComXResult>0){
- SpaceSelect(hIMC,wParam);
- szPreResultCode[wStrLen-1]=_T(' ');
- _tcscpy(lpStr,lpStr+wStrLen-1);
- lpCompStr->dwCompStrLen = wStrLen = _tcslen(lpStr);
- }
- else if(ComXResult==0){
- if(_tcscmp(lpStr,wubiDictCurrent->strCode)<0){
- SpaceSelect(hIMC,wParam);
- szPreResultCode[wStrLen-1]=_T(' ');
- _tcscpy(lpStr,lpStr+wStrLen-1);
- lpCompStr->dwCompStrLen = wStrLen = _tcslen(lpStr);
- }
- else if(_tcscmp(lpStr,wubiDictCurrent->strCode)>0){
- recTemp=wubiDictCurrent;
- while(recTemp->next!=wubiDictHead->prev&&
- _tcscmp(lpStr,recTemp->strCode)>0)
- recTemp=recTemp->next;
- ComXResult=(int)CompareWBCodeX(lpStr,recTemp->strCode);
- ComXResult-=MaxCompareWBCodeX-wStrLen;
- if(_tcscmp(lpStr,recTemp->strCode)<0 && ComXResult>0){
- SpaceSelect(hIMC,wParam);
- szPreResultCode[wStrLen-1]=_T(' ');
- _tcscpy(lpStr,lpStr+wStrLen-1);
- lpCompStr->dwCompStrLen = wStrLen = _tcslen(lpStr);
- }
- }
- }
- }
- CodeForward=1;
- //依编码查找五笔//加快速度的方案
- if(wStrLen<2)
- //wubiDictCurrent = wubiDictHead->next;
- //if(cFirstChr=*lpStr)
- {
- SetwubiFirstLeadChr((TCHAR)wParam);
- wubiDictCurrent=wubiFirstLeadChr[(TCHAR)wParam-_T('!')];
- }
- //else
- else wubiDictCurrent = wubiDictCurrentRecord;
- while (wubiDictCurrent != wubiDictHead->prev) {
- if (_tcscmp(lpStr, wubiDictCurrent->strCode)<=0) {
- if (_tcscmp(lpStr,wubiDictCurrent->strCode)<0) {
- lpCandList->dwCount=0;
- break;
- }
- wubiDictCurrentRecord=wubiDictCurrent;
- //
- for( i=0,k=2;i<CAND_PAGESIZE;i++){//MAXCANDSTRNUM
- if(wubiDictCurrent == wubiDictHead->prev) break;
- if(_tcscmp (lpStr, wubiDictCurrent->strCode)) break;
- if(!(wConversionSet & CONVERSION_SET_GBK) &&
- !IsStringGb2312(wubiDictCurrent->strHZ)) {
- wubiDictCurrent = wubiDictCurrent->next;
- continue;
- }
- //取消对非gb2312字的上屏
- _tcscpy(GETLPCANDSTR(lpCandList,k),wubiDictCurrent->strHZ);
- k++;
- wubiDictCurrent = wubiDictCurrent->next;
- }
- lpCandList->dwCount =k-2;
- break;
- }
- wubiDictCurrent = wubiDictCurrent->next;
- }
- //如果自动加词找到与输入编码相同词组,则添加于最后。//如果自动词与最后一项相同,不显示
- if(HaveAutoCandList){
- k=0;//重复利用k作为标志
- recTemp=wubiDictCurrentRecord;
- while(_tcscmp(lpStr,recTemp->strCode)<=0 && recTemp!=wubiDictHead->next)
- recTemp=recTemp->prev;
- while(_tcscmp(lpStr,recTemp->strCode)>=0 && recTemp!=wubiDictHead->prev){
- if(!strcmp(AutoWuBiWord,recTemp->strHZ)){//清除
- k=1;
- if((wConversionSet1 & C_SET1_ERBIMAKEWORD)?
- !ReturnHaveAutoCandListErbi(lpStr,GETLPCANDSTR(lpCandList,2+i)):
- !ReturnHaveAutoCandList(lpStr,GETLPCANDSTR(lpCandList,2+i))){//二次造词
- HaveAutoCandList=0;
- goto NoAddAutoMakeWord;//如果二次造词失败
- }
- }
- recTemp=recTemp->next;
- }
- if(k==1){
- recTemp=wubiDictCurrentRecord;
- while(_tcscmp(lpStr,recTemp->strCode)<=0 && recTemp!=wubiDictHead->next)
- recTemp=recTemp->prev;
- while(_tcscmp(lpStr,recTemp->strCode)>=0 && recTemp!=wubiDictHead->prev){
- if(!strcmp(AutoWuBiWord,recTemp->strHZ)){
- HaveAutoCandList=0;
- goto NoAddAutoMakeWord;//二次清除
- }
- recTemp=recTemp->next;
- }
- }
- _tcscpy(YJMMessage,_T("(自动造词:)"));//提示
- _tcscpy(GETLPCANDSTR(lpCandList,2+lpCandList->dwCount),AutoWuBiWord);
- lpCandList->dwCount +=1;
- }
- NoAddAutoMakeWord:
- CodeHintTextBegin=lpCandList->dwCount;
- if(wConversionSet1 & C_SET1_CODE_HINT){
- for(i=0;i<lpCandList->dwCount;i++)
- _tcscpy(CodeHintText[i],"");
- recTemp=wubiDictCurrent;
- while(lpCandList->dwCount<CAND_PAGESIZE && recTemp != wubiDictHead->prev){
- _tcscpy(GETLPCANDSTR(lpCandList,2+lpCandList->dwCount),recTemp->strHZ);
- _tcscpy(CodeHintText[lpCandList->dwCount],recTemp->strCode);
- recTemp = recTemp->next;
- lpCandList->dwCount +=1;
- }
- }
- ComXResult=(int)CompareWBCodeX(lpStr,wubiDictCurrent->strCode);
- ComXResult-=MaxCompareWBCodeX-wStrLen;
- if(!HaveAutoCandList && wStrLen>2&&
- wubiDictCurrent!=wubiDictHead->prev){
- if((lpCandList->dwCount ==1)&&
- ComXResult>0 &&
- (wConversionSet1 & C_SET1_AUTO_INPUT)){//单个选项自动上屏
- SpaceSelect(hIMC,wParam);
- goto yjmwubidisplay;
- }
- }
- }
- //以上接收键盘输入a-z
- //翻页功能
- else if( wParam == _T('=') || wParam == _T('>')) {//wParam == _T('.') || //与符号推字冲突
- //SelectForwardFromCand(hIMC,lpCandList);
- UINT i;
- if(wConversionSet1 & C_SET1_CODE_HINT)
- for(i=0;i<CAND_PAGESIZE && wubiDictCurrentRecord!=wubiDictHead->prev;i++){
- wubiDictCurrentRecord=wubiDictCurrentRecord->next;
- }
- else wubiDictCurrentRecord=wubiDictCurrent;
- wParam=*(lpStr+wStrLen-1);
- *(lpStr+wStrLen-1)=_T(' ');
- CodeForward=0;
- ImmUnlockIMCC(lpIMC->hCompStr);
- ImmUnlockIMC(hIMC);
- CharHandleWuBi(hIMC,wParam,0);
- }
- else if( wParam == _T('-') || wParam == _T('<')) {//wParam == _T(',') ||
- //SelectBackwardFromCand(hIMC,lpCandList);
- UINT i;
- for(i=0;i<CAND_PAGESIZE && wubiDictCurrentRecord!=wubiDictHead->next;i++){
- wubiDictCurrentRecord=wubiDictCurrentRecord->prev;
- }
- wParam=*(lpStr+wStrLen-1);
- *(lpStr+wStrLen-1)=_T(' ');
- CodeForward=0;
- ImmUnlockIMCC(lpIMC->hCompStr);
- ImmUnlockIMC(hIMC);
- CharHandleWuBi(hIMC,wParam,0);
- }
- //选择功能1234567890
- else if( wParam >= _T('0') && wParam <= _T('9') ){
- if( !IsCompStr(hIMC)) return FALSE;//如果首键是数字,放行。
- SelectCandFromCandlist(hIMC, wParam);
- }
- //选用第二候选词的方便键
- else if((wParam == _T(';')||(wConversionSet1 & C_SET1_FIRSTCODEPUNCT && wParam == _T('[')))&&lpCandList->dwCount >=2){
- SelectCandFromCandlist(hIMC, _T('2'));
- }
- //选用第三候选词的方便键
- else if((wParam == _T(''')||(wConversionSet1 & C_SET1_FIRSTCODEPUNCT && wParam == _T(']')))&&lpCandList->dwCount >=3){
- SelectCandFromCandlist(hIMC, _T('3'));
- }
- //符号推字上屏
- else if( wParam == _T('!')||wParam == _T('@')||wParam == _T('#')||wParam == _T('$')||
- wParam == _T('%')||wParam == _T('^')||wParam == _T('&')||wParam == _T('*')||
- wParam == _T('(')||wParam == _T(')')||wParam == _T(',')||wParam == _T('.')||
- wParam == _T(';')||wParam == _T(''')||wParam == _T('\')||wParam == _T('/')||
- wParam == _T(':')||wParam == _T('"')||wParam == _T('?')||
- wParam == _T('[')||wParam == _T(']')||wParam == _T('{')||wParam == _T('}')){
- PunctPushWordFlag=1;
- SelectCandFromCandlist( hIMC, _T('1'));
- PunctPushWordFlag=0;
- GeneratePunct(hIMC,wParam);
- return TRUE;
- }
- else {
- ImmUnlockIMCC(lpIMC->hCompStr);
- ImmUnlockIMCC(lpIMC->hCandInfo);
- ImmUnlockIMC(hIMC);
- return FALSE;
- }
- //显示
- yjmwubidisplay:
- lpStr1 = ((LPMYCOMPSTR)lpCompStr)->FreePYComp.szPaintCompStr;
- _tcscpy(lpStr1,lpStr);
- ((LPMYCOMPSTR)lpCompStr)->FreePYComp.wEditCaret=_tcslen(lpStr1);
- if(wConversionSet & CONVERSION_SET_WBSPEED) _tcscat(lpStr1,SpeedMessage);//显示提示YJMMessage
- _tcscat(lpStr1,YJMMessage);
- GnMsg.msg = WM_IME_COMPOSITION;
- GnMsg.wParam = 0;
- GnMsg.lParam = GCS_COMPSTR;
- GenerateMessage(hIMC, lpdwCurTransKey,(LPGENEMSG)&GnMsg);
- //yjmwubiexit:
- ImmUnlockIMCC(lpIMC->hCompStr);
- ImmUnlockIMCC(lpIMC->hCandInfo);
- ImmUnlockIMC(hIMC);
- return TRUE;
- }
- UINT ReturnHaveAutoCandList(LPTSTR lpStr,LPTSTR lpNoStr)
- {
- WORD i,AutoWuBiBeginNum;
- char TempAutoWubi[1024];
- WordHistoryStrLen=_tcslen(WordHistoryStr);
- for(i=4;i<=MAXAUTOWUBINUM && i<=WordHistoryStrLen;i+=2){
- AutoWuBiBeginNum=WordHistoryStrLen-i;
- if(*(HistoryTwoCodes+AutoWuBiBeginNum)==*lpStr){//首码相同
- //双字词
- if(*(HistoryTwoCodes+AutoWuBiBeginNum+1)==*(lpStr+1)&&
- *(HistoryTwoCodes+AutoWuBiBeginNum+2)==*(lpStr+2)&&
- *(HistoryTwoCodes+AutoWuBiBeginNum+3)==*(lpStr+3)){
- _tcscpy(AutoWuBiCode,lpStr);
- _tcscpy(AutoWuBiCode1,AutoWuBiCode);
- //取得两汉字串
- _tcscpy(TempAutoWubi,WordHistoryStr+AutoWuBiBeginNum);
- TempAutoWubi[4]=' ';
- _tcscpy(AutoWuBiWord,TempAutoWubi);
- if(_tcscmp(AutoWuBiWord,lpNoStr)!=0)
- return 1;
- }
- //多于三字词
- if(i>=6){//二、三码相同
- if(*(HistoryTwoCodes+AutoWuBiBeginNum+2)==*(lpStr+1)&&
- *(HistoryTwoCodes+AutoWuBiBeginNum+4)==*(lpStr+2)){
- //三字词
- if(*(HistoryTwoCodes+AutoWuBiBeginNum+5)==*(lpStr+3)){
- _tcscpy(AutoWuBiCode,lpStr);
- _tcscpy(AutoWuBiCode1,AutoWuBiCode);
- //取得三汉字串
- _tcscpy(TempAutoWubi,WordHistoryStr+AutoWuBiBeginNum);
- TempAutoWubi[6]=' ';
- _tcscpy(AutoWuBiWord,TempAutoWubi);
- if(_tcscmp(AutoWuBiWord,lpNoStr)!=0)
- return 1;
- }
- //四字词
- if(i>=8){
- if(*(HistoryTwoCodes+AutoWuBiBeginNum+6)==*(lpStr+3)){
- _tcscpy(AutoWuBiCode,lpStr);
- _tcscpy(AutoWuBiCode1,AutoWuBiCode);
- //取得四汉字串
- _tcscpy(TempAutoWubi,WordHistoryStr+AutoWuBiBeginNum);
- TempAutoWubi[8]=' ';
- _tcscpy(AutoWuBiWord,TempAutoWubi);
- if(_tcscmp(AutoWuBiWord,lpNoStr)!=0)
- return 1;
- }
- }
- //五字词
- if(i>=10){
- if(*(HistoryTwoCodes+AutoWuBiBeginNum+8)==*(lpStr+3)){
- _tcscpy(AutoWuBiCode,lpStr);
- _tcscpy(AutoWuBiCode1,AutoWuBiCode);
- //取得五汉字串
- _tcscpy(TempAutoWubi,WordHistoryStr+AutoWuBiBeginNum);
- TempAutoWubi[10]=' ';
- _tcscpy(AutoWuBiWord,TempAutoWubi);
- if(_tcscmp(AutoWuBiWord,lpNoStr)!=0)
- return 1;
- }
- }
- //六字词
- if(i>=12){
- if(*(HistoryTwoCodes+AutoWuBiBeginNum+10)==*(lpStr+3)){
- _tcscpy(AutoWuBiCode,lpStr);
- _tcscpy(AutoWuBiCode1,AutoWuBiCode);
- //取得六汉字串
- _tcscpy(TempAutoWubi,WordHistoryStr+AutoWuBiBeginNum);
- TempAutoWubi[12]=' ';
- _tcscpy(AutoWuBiWord,TempAutoWubi);
- if(_tcscmp(AutoWuBiWord,lpNoStr)!=0)
- return 1;
- }
- }
- //七字词
- if(i>=14){
- if(*(HistoryTwoCodes+AutoWuBiBeginNum+12)==*(lpStr+3)){
- _tcscpy(AutoWuBiCode,lpStr);
- _tcscpy(AutoWuBiCode1,AutoWuBiCode);
- //取得七汉字串
- _tcscpy(TempAutoWubi,WordHistoryStr+AutoWuBiBeginNum);
- TempAutoWubi[14]=' ';
- _tcscpy(AutoWuBiWord,TempAutoWubi);
- if(_tcscmp(AutoWuBiWord,lpNoStr)!=0)
- return 1;
- }
- }
- //八字词
- if(i>=16){
- if(*(HistoryTwoCodes+AutoWuBiBeginNum+14)==*(lpStr+3)){
- _tcscpy(AutoWuBiCode,lpStr);
- _tcscpy(AutoWuBiCode1,AutoWuBiCode);
- //取得八汉字串
- _tcscpy(TempAutoWubi,WordHistoryStr+AutoWuBiBeginNum);
- TempAutoWubi[16]=' ';
- _tcscpy(AutoWuBiWord,TempAutoWubi);
- if(_tcscmp(AutoWuBiWord,lpNoStr)!=0)
- return 1;
- }
- }
- }//二、三码相同
- }
- }//首码相同
- }
- return 0;
- }
- UINT ReturnHaveAutoCandListErbi(LPTSTR lpStr,LPTSTR lpNoStr)
- {
- WORD i,AutoWuBiBeginNum;
- char TempAutoWubi[1024];
- WordHistoryStrLen=_tcslen(WordHistoryStr);
- for(i=4;i<=MAXAUTOWUBINUM && i<=WordHistoryStrLen;i+=2){
- AutoWuBiBeginNum=WordHistoryStrLen-i;
- if(*(HistoryTwoCodes+AutoWuBiBeginNum)==*lpStr){//首码相同
- //二,三字词
- if(*(HistoryTwoCodes+AutoWuBiBeginNum+1)==*(lpStr+1)&&
- *(HistoryTwoCodes+AutoWuBiBeginNum+2)==*(lpStr+2)){//次码三码相同
- //二字词
- if(*(HistoryTwoCodes+AutoWuBiBeginNum+3)==*(lpStr+3)){//四码相同
- _tcscpy(AutoWuBiCode,lpStr);
- _tcscpy(AutoWuBiCode1,AutoWuBiCode);
- //取得两汉字串
- _tcscpy(TempAutoWubi,WordHistoryStr+AutoWuBiBeginNum);
- TempAutoWubi[4]=' ';
- _tcscpy(AutoWuBiWord,TempAutoWubi);
- if(_tcscmp(AutoWuBiWord,lpNoStr)!=0)
- return 1;
- }
- //三字词
- if(i>=6){//四码相同
- if(*(HistoryTwoCodes+AutoWuBiBeginNum+4)==*(lpStr+3)){
- _tcscpy(AutoWuBiCode,lpStr);
- _tcscpy(AutoWuBiCode1,AutoWuBiCode);
- //取得三汉字串
- _tcscpy(TempAutoWubi,WordHistoryStr+AutoWuBiBeginNum);
- TempAutoWubi[6]=' ';
- _tcscpy(AutoWuBiWord,TempAutoWubi);
- if(_tcscmp(AutoWuBiWord,lpNoStr)!=0)
- return 1;
- }
- }
- }
- //多于四字词
- if(i>=8){//二、三码相同
- if(*(HistoryTwoCodes+AutoWuBiBeginNum+2)==*(lpStr+1)&&
- *(HistoryTwoCodes+AutoWuBiBeginNum+4)==*(lpStr+2)){
- //四字词
- if(i>=8){
- if(*(HistoryTwoCodes+AutoWuBiBeginNum+6)==*(lpStr+3)){
- _tcscpy(AutoWuBiCode,lpStr);
- _tcscpy(AutoWuBiCode1,AutoWuBiCode);
- //取得四汉字串
- _tcscpy(TempAutoWubi,WordHistoryStr+AutoWuBiBeginNum);
- TempAutoWubi[8]=' ';
- _tcscpy(AutoWuBiWord,TempAutoWubi);
- if(_tcscmp(AutoWuBiWord,lpNoStr)!=0)
- return 1;
- }
- }
- //五字词
- if(i>=10){
- if(*(HistoryTwoCodes+AutoWuBiBeginNum+8)==*(lpStr+3)){
- _tcscpy(AutoWuBiCode,lpStr);
- _tcscpy(AutoWuBiCode1,AutoWuBiCode);
- //取得五汉字串
- _tcscpy(TempAutoWubi,WordHistoryStr+AutoWuBiBeginNum);
- TempAutoWubi[10]=' ';
- _tcscpy(AutoWuBiWord,TempAutoWubi);
- if(_tcscmp(AutoWuBiWord,lpNoStr)!=0)
- return 1;
- }
- }
- //六字词
- if(i>=12){
- if(*(HistoryTwoCodes+AutoWuBiBeginNum+10)==*(lpStr+3)){
- _tcscpy(AutoWuBiCode,lpStr);
- _tcscpy(AutoWuBiCode1,AutoWuBiCode);
- //取得六汉字串
- _tcscpy(TempAutoWubi,WordHistoryStr+AutoWuBiBeginNum);
- TempAutoWubi[12]=' ';
- _tcscpy(AutoWuBiWord,TempAutoWubi);
- if(_tcscmp(AutoWuBiWord,lpNoStr)!=0)
- return 1;
- }
- }
- //七字词
- if(i>=14){
- if(*(HistoryTwoCodes+AutoWuBiBeginNum+12)==*(lpStr+3)){
- _tcscpy(AutoWuBiCode,lpStr);
- _tcscpy(AutoWuBiCode1,AutoWuBiCode);
- //取得七汉字串
- _tcscpy(TempAutoWubi,WordHistoryStr+AutoWuBiBeginNum);
- TempAutoWubi[14]=' ';
- _tcscpy(AutoWuBiWord,TempAutoWubi);
- if(_tcscmp(AutoWuBiWord,lpNoStr)!=0)
- return 1;
- }
- }
- //八字词
- if(i>=16){
- if(*(HistoryTwoCodes+AutoWuBiBeginNum+14)==*(lpStr+3)){
- _tcscpy(AutoWuBiCode,lpStr);
- _tcscpy(AutoWuBiCode1,AutoWuBiCode);
- //取得八汉字串
- _tcscpy(TempAutoWubi,WordHistoryStr+AutoWuBiBeginNum);
- TempAutoWubi[16]=' ';
- _tcscpy(AutoWuBiWord,TempAutoWubi);
- if(_tcscmp(AutoWuBiWord,lpNoStr)!=0)
- return 1;
- }
- }
- }//二、三码相同
- }
- }//首码相同
- }
- return 0;
- }
- int CDECL MessageBoxPrintf (TCHAR * szCaption, TCHAR * szFormat, ...)
- {
- TCHAR szBuffer [1024] ;
- va_list pArgList ;
- // The va_start macro (defined in STDARG.H) is usually equivalent to:
- // pArgList = (char *) &szFormat + sizeof (szFormat) ;
- va_start (pArgList, szFormat) ;
- // The last argument to wvsprintf points to the arguments
- _vsntprintf ( szBuffer, sizeof (szBuffer) / sizeof (TCHAR),szFormat, pArgList) ;
- // The va_end macro just zeroes out pArgList for no good reason
- va_end (pArgList) ;
- return MessageBox (NULL, szBuffer, szCaption, 0);
- }