Notify.pas
资源名称:Wingb_Mz.rar [点击查看]
上传用户:wen198501
上传日期:2013-04-01
资源大小:335k
文件大小:22k
源码类别:
输入法编程
开发平台:
Delphi
- {******************************************************}
- { }
- { Copyright (c) 1990-1999 Microsoft Corporation }
- { }
- { Module Name: Notify.c ->> Notify.pas }
- { }
- { Translator: Liu_mazi@126.com, 2005-11-16 }
- { }
- {******************************************************}
- unit Notify;
- {$I Define.Inc}
- interface
- uses Windows, ImmDev, ImeDefs;
- procedure CompCancel(_hIMC: hIMC; lpIMC: PInputContext);
- procedure GenerateMessage(_hIMC: hIMC; lpIMC: PInputContext; lpImcP: PPrivContext);
- function NotifyIME(_hIMC: hIMC; dwAction: DWord; dwIndex: DWord; dwValue: DWord): Bool; stdcall;
- function ImeSetCompositionString(_hIMC: hIMC; dwIndex: DWord; lpComp: Pointer; dwCompLen: DWord; lpRead: Pointer; dwReadLen: DWord): Bool; stdcall;
- implementation
- uses DDIS, ToAscii, Chcand, Compose, LogText;
- // 消息发送, **
- procedure GenerateMessage(_hIMC: hIMC; lpIMC: PInputContext; lpImcP: PPrivContext);
- begin
- if (_hIMC = 0) or (lpIMC = nil) or (lpImcP = nil) then Exit;
- if (lpImcP.fdwImeMsg and MSG_IN_IMETOASCIIEX) <> 0 then Exit;
- Inc(lpIMC.dwNumMsgBuf, TranslateImeMessage(nil, lpIMC, lpImcP));
- lpImcP.fdwImeMsg := lpImcP.fdwImeMsg and (MSG_ALREADY_OPEN or MSG_ALREADY_START);
- lpImcP.fdwGcsFlag := 0;
- ImmGenerateMessage(_hIMC);
- end;
- // 消息发送
- procedure GenerateImeMessage(_hIMC: hIMC; lpIMC: PInputContext; fdwImeMsg: DWord);
- var
- lpImcP: PPrivContext;
- begin
- lpImcP := ImmLockIMCC(lpIMC.hPrivate);
- if (lpImcP = nil) then Exit;
- lpImcP.fdwImeMsg := lpImcP.fdwImeMsg or fdwImeMsg;
- if (fdwImeMsg and MSG_CLOSE_CANDIDATE) <> 0 then
- begin
- lpImcP.fdwImeMsg := lpImcP.fdwImeMsg and not (MSG_OPEN_CANDIDATE or MSG_CHANGE_CANDIDATE);
- end else
- if fdwImeMsg and (MSG_OPEN_CANDIDATE or MSG_CHANGE_CANDIDATE) <> 0 then
- begin
- lpImcP.fdwImeMsg := lpImcP.fdwImeMsg and (not MSG_CLOSE_CANDIDATE);
- end;
- if (fdwImeMsg and MSG_END_COMPOSITION) <> 0 then
- begin
- lpImcP.fdwImeMsg := lpImcP.fdwImeMsg and (not MSG_START_COMPOSITION);
- end else
- if (fdwImeMsg and MSG_START_COMPOSITION) <> 0 then
- begin
- lpImcP.fdwImeMsg := lpImcP.fdwImeMsg and (not MSG_END_COMPOSITION);
- end;
- GenerateMessage(_hIMC, lpIMC, lpImcP);
- ImmUnlockIMCC(lpIMC.hPrivate);
- end;
- // 取消Composition
- procedure CompCancel(_hIMC: hIMC; lpIMC: PInputContext);
- var
- lpImcP: PPrivContext;
- lpCompStr: PCompositionString;
- lpGuideLine: PGuideLine;
- begin
- if (lpIMC.hPrivate = 0) then Exit;
- lpImcP := ImmLockIMCC(lpIMC.hPrivate);
- if (lpImcP = nil) then Exit;
- lpImcP.fdwGcsFlag := 0;
- if (lpImcP.fdwImeMsg and MSG_ALREADY_OPEN) <> 0 then
- begin
- CandEscapeKey(lpIMC, lpImcP);
- end else
- if (lpImcP.fdwImeMsg and MSG_ALREADY_START) <> 0 then
- begin
- lpCompStr := ImmLockIMCC(lpIMC.hCompStr);
- if (lpCompStr = nil) then
- begin
- ImmUnlockIMCC(lpIMC.hCompStr);
- ImmUnlockIMCC(lpIMC.hPrivate);
- Exit;
- end;
- lpGuideLine := ImmLockIMCC(lpIMC.hGuideLine);
- if (lpGuideLine = nil) then
- begin
- ImmUnlockIMCC(lpIMC.hCompStr); // **
- ImmUnlockIMCC(lpIMC.hGuideLine);
- ImmUnlockIMCC(lpIMC.hPrivate);
- Exit;
- end;
- CompEscapeKey(lpIMC, lpCompStr, lpGuideLine, lpImcP);
- if (lpGuideLine <> nil) then ImmUnlockIMCC(lpIMC.hGuideLine);
- if (lpCompStr <> nil) then ImmUnlockIMCC(lpIMC.hCompStr);
- end else
- begin
- ImmUnlockIMCC(lpIMC.hPrivate);
- Exit;
- end;
- GenerateMessage(_hIMC, lpIMC, lpImcP);
- ImmUnlockIMCC(lpIMC.hPrivate);
- end;
- // 设置字符串, **
- function SetString(_hIMC: hIMC; lpIMC: PInputContext; lpCompStr: PCompositionString;
- lpImcP: PPrivContext; lpszRead: PChar; dwReadLen: DWord): Bool;
- label
- Finalize;
- var
- lpCandList: PCandidateList;
- lpCandInfo: PCandidateInfo;
- lpGuideLine: PGuideLine;
- iRet, ii, Max_Comp, i: uInt;
- wCode: Word;
- begin
- Result := False;
- lStrCpy(lpImcP.bSeq, lpszRead);
- if (lpImcP.bSeq[3] = '?') then Max_Comp := 94 else Max_Comp := 1;
- if (dwReadLen > 4) then Exit; // return (FALSE);
- lpCandInfo := ImmLockIMCC(lpIMC.hCandInfo);
- if (lpCandInfo = nil) then
- begin
- Result := Bool(-1);
- Exit;
- end;
- // get lpCandList and init dwCount & dwSelection
- lpCandList := PCandidateList(DWord(lpCandInfo) + lpCandInfo.dwOffset[0]);
- InitCompStr(lpCompStr);
- ClearCand(lpIMC);
- lpGuideLine := ImmLockIMCC(lpIMC.hGuideLine);
- if (lpGuideLine <> nil) then ImmUnlockIMCC(lpIMC.hGuideLine); // ??
- CopyMemory(Pointer(DWord(lpCompStr) + lpCompStr.dwCompReadStrOffset), lpszRead, dwReadLen + SizeOf(Char));
- CopyMemory(Pointer(DWord(lpCompStr) + lpCompStr.dwCompStrOffset), lpszRead, dwReadLen + SizeOf(Char));
- lpCompStr.dwCompReadAttrLen := dwReadLen;
- lpCompStr.dwCompAttrLen := lpCompStr.dwCompReadAttrLen;
- for I := 0 to dwReadLen - 1 do // The IME has converted these chars
- PByte(DWord(lpCompStr) + lpCompStr.dwCompReadAttrOffset + I)^ := ATTR_TARGET_CONVERTED;
- lpCompStr.dwCompReadStrLen := dwReadLen;
- lpCompStr.dwCompStrLen := lpCompStr.dwCompReadStrLen;
- // dlta start from 0;
- lpCompStr.dwDeltaStart := 0;
- // cursor is next to composition string
- lpCompStr.dwCursorPos := lpCompStr.dwCompStrLen;
- lpCompStr.dwResultReadClauseLen := 0;
- lpCompStr.dwResultReadStrLen := 0;
- lpCompStr.dwResultClauseLen := 0;
- lpCompStr.dwResultStrLen := 0;
- // set private input context
- lpImcP.iImeState := CST_INPUT;
- if (lpImcP.fdwImeMsg and MSG_ALREADY_OPEN) <> 0 then
- lpImcP.fdwImeMsg := (lpImcP.fdwImeMsg or MSG_CLOSE_CANDIDATE) and (not MSG_OPEN_CANDIDATE);
- if (lpImcP.fdwImeMsg and MSG_ALREADY_START) = 0 then
- lpImcP.fdwImeMsg := (lpImcP.fdwImeMsg or MSG_START_COMPOSITION) and (not MSG_END_COMPOSITION);
- lpImcP.fdwImeMsg := lpImcP.fdwImeMsg or MSG_COMPOSITION;
- lpImcP.fdwGcsFlag := GCS_COMPREAD or GCS_COMP or GCS_DELTASTART or GCS_CURSORPOS;
- lpImcP.fdwImeMsg := lpImcP.fdwImeMsg or MSG_GUIDELINE;
- lpCandList.dwCount := 0;
- if (dwReadLen < 4) then goto Finalize;
- lpImcP.bSeq[0] := #0;
- lpImcP.bSeq[1] := #0;
- lpImcP.bSeq[2] := #0;
- lpImcP.bSeq[3] := #0;
- for ii := 0 to 3 do
- begin
- iRet := GBProcessKey(PByte(DWord(@lpszRead) + ii)^, lpImcP);
- if (iRet = CST_INPUT) then lpImcP.bSeq[ii] := PChar(DWord(@lpszRead) + ii)^ else goto Finalize;
- end;
- wCode := GBEngine(lpImcP);
- wCode := HiByte(wCode) or (LoByte(wCode) shl 8);
- for i := 0 to Max_Comp - 1 do
- begin
- AddCodeIntoCand(lpCandList, wCode);
- Inc(wCode);
- end;
- if (lpCandList.dwCount = 1) then
- begin
- lStrCpy(PChar(DWord(lpCompStr) + lpCompStr.dwResultStrOffset), PChar(DWord(lpCandList) + lpCandList.dwOffset[0]));
- // calculate result string length
- lpCompStr.dwResultStrLen := lStrLen(PChar(DWord(lpCandList) + lpCandList.dwOffset[0]));
- lpImcP.fdwImeMsg := lpImcP.fdwImeMsg or MSG_COMPOSITION;
- lpImcP.dwCompChar := 0;
- lpImcP.fdwGcsFlag := lpImcP.fdwGcsFlag or GCS_CURSORPOS or GCS_RESULTREAD or GCS_RESULT;
- if ((lpImcP.fdwImeMsg and MSG_ALREADY_OPEN) <> 0) then
- lpImcP.fdwImeMsg := (lpImcP.fdwImeMsg or MSG_CLOSE_CANDIDATE) and (not MSG_OPEN_CANDIDATE)
- else
- lpImcP.fdwImeMsg := lpImcP.fdwImeMsg and (not (MSG_CLOSE_CANDIDATE or MSG_OPEN_CANDIDATE));
- lpImcP.iImeState := CST_INIT;
- PDWord(@lpImcP.bSeq)^ := 0;
- lpCandList.dwCount := 0;
- end else
- if (lpCandList.dwCount > 1) then
- lpImcP.fdwImeMsg := (lpImcP.fdwImeMsg or MSG_OPEN_CANDIDATE) and (not MSG_CLOSE_CANDIDATE)
- else
- if(lpCandList.dwCount = 0) then
- lpImcP.fdwImeMsg := (lpImcP.fdwImeMsg or MSG_CLOSE_CANDIDATE) and (not MSG_OPEN_CANDIDATE);
- Finalize:
- GenerateMessage(_hIMC, lpIMC, lpImcP);
- Result := True;
- end;
- // Ime回调, **
- function ImeSetCompositionString(_hIMC: hIMC; dwIndex: DWord; lpComp: Pointer;
- dwCompLen: DWord; lpRead: Pointer; dwReadLen: DWord): Bool; stdcall;
- var
- lpIMC: PInputContext;
- lpCompStr: PCompositionString;
- lpImcP: PPrivContext;
- // fRet: Bool;
- begin
- Result := False;
- if (_hIMC = 0) then Exit; // return (FALSE);
- // composition string must == reading string reading is more important
- if (dwReadLen = 0) then dwReadLen := dwCompLen;
- // composition string must == reading string, reading is more important
- if (lpRead = nil) then lpRead := lpComp;
- if (dwReadLen = 0) then
- begin
- lpIMC := ImmLockIMC(_hIMC);
- if (lpIMC = nil) then Exit; // return (FALSE);
- CompCancel(_hIMC, lpIMC);
- ImmUnlockIMC(_hIMC);
- Result := True;
- Exit; // return (TRUE);
- end else
- if (lpRead = nil) then
- begin
- Exit; // return (FALSE);
- end else
- if (dwCompLen = 0) then
- begin
- end else
- if (lpComp = nil) then
- begin
- end else
- if (dwReadLen <> dwCompLen) then
- begin
- Exit; // return (FALSE);
- end else
- if (lpRead = lpComp) then
- begin
- end else
- if (lStrCmp(lpRead, lpComp) = 0) then
- begin
- // composition string must == reading string
- end else
- begin
- // composition string != reading string
- Exit; // return (FALSE);
- end;
- if (dwIndex <> SCS_SETSTR) then Exit; // return (FALSE);
- lpIMC := ImmLockIMC(_hIMC);
- if (lpIMC = nil) then Exit; // return (FALSE);
- if (lpIMC.hCompStr = 0) then
- begin
- ImmUnlockIMC(_hIMC);
- Exit; // return (FALSE);
- end;
- lpCompStr := ImmLockIMCC(lpIMC.hCompStr);
- if (lpCompStr = nil) then
- begin
- ImmUnlockIMC(_hIMC);
- Exit; // return (FALSE);
- end;
- lpImcP := ImmLockIMCC(lpIMC.hPrivate);
- if (lpCompStr = nil) then
- begin
- ImmUnlockIMCC(lpIMC.hCompStr);
- ImmUnlockIMC(_hIMC);
- Exit; // return (FALSE);
- end;
- Result := SetString(_hIMC, lpIMC, lpCompStr, lpImcP, lpRead, dwReadLen);
- ImmUnlockIMCC(lpIMC.hPrivate);
- ImmUnlockIMCC(lpIMC.hCompStr);
- ImmUnlockIMC(_hIMC);
- end;
- // app tell IME that one candidate string is selected (by mouse or non keyboard actionfor example sound)
- procedure NotifySelectCand(_hIMC: hIMC; lpIMC: PInputContext; lpCandInfo: PCandiDateInfo; dwIndex, dwValue: DWord);
- var
- lpCandList: PCandiDateList;
- lpCompStr: PCompositionString;
- lpImcP: PPrivContext;
- begin
- if (lpCandInfo = nil) then Exit;
- if (dwIndex >= lpCandInfo.dwCount) then
- begin
- Exit; // wanted candidate list is not created yet!
- end else
- if (dwIndex = 0) then
- begin
- if (lpIMC.fdwConversion and IME_CMODE_CHARCODE) <> 0 then
- begin
- Exit; // not implemented yet
- end;
- end;
- lpCandList := PCandiDateList(DWord(lpCandInfo) + lpCandInfo.dwOffset[0]);
- // the selected value even more than the number of total candidate strings, it is imposible. should be error of app
- if (dwValue >= lpCandList.dwCount) then Exit;
- // app select this candidate string
- lpCandList.dwSelection := dwValue;
- lpCompStr := ImmLockIMCC(lpIMC.hCompStr);
- if (lpCompStr = nil) then Exit;
- lpImcP := ImmLockIMCC(lpIMC.hPrivate);
- if (lpCompStr = nil) then
- begin
- ImmUnlockIMCC(lpIMC.hCompStr);
- Exit;
- end;
- // translate into message buffer
- SelectOneCand(lpIMC, lpCompStr, lpImcP, lpCandList);
- // let app generate those messages in its message loop
- GenerateMessage(_hIMC, lpIMC, lpImcP);
- ImmUnlockIMCC(lpIMC.hPrivate);
- ImmUnlockIMCC(lpIMC.hCompStr);
- end;
- // Ime回调, **
- function NotifyIME(_hIMC: hIMC; dwAction: DWord; dwIndex: DWord; dwValue: DWord): Bool; stdcall;
- label
- NotifyIMEUnlock;
- var
- lpIMC: PInputContext;
- fdwImeMsg: DWord;
- lpCandInfo: PCandidateInfo;
- lpCandList: PCandidateList;
- lpImcP: PPrivContext;
- lpCompStr: PCompositionString;
- lpGuideLine: PGuideLine;
- begin
- Result := False;
- if (_hIMC = 0) then Exit;
- case (dwAction) of
- NI_OPENCANDIDATE,
- NI_CLOSECANDIDATE:
- Exit; // not supported
- NI_SELECTCANDIDATESTR,
- NI_SETCANDIDATE_PAGESTART,
- NI_SETCANDIDATE_PAGESIZE:
- ; // need to handle it
- NI_CHANGECANDIDATELIST:
- ;
- NI_CONTEXTUPDATED:
- case (dwValue) of
- IMC_SETCONVERSIONMODE,
- IMC_SETOPENSTATUS:
- ; // need to handle it
- IMC_SETCANDIDATEPOS,
- IMC_SETCOMPOSITIONFONT,
- IMC_SETCOMPOSITIONWINDOW:
- begin
- Result := True;
- Exit; // not important to the IME
- end;
- else Exit; // not supported
- end;
- NI_COMPOSITIONSTR:
- case (dwIndex) of
- CPS_COMPLETE:
- ; // need to handle it
- CPS_CONVERT, // all composition string can not be convert
- CPS_REVERT: // any more, it maybe work for some intelligent phonetic IMEs
- Exit;
- CPS_CANCEL:
- ; // need to handle it
- else Exit; // not supported
- end; // need to handle it
- else Exit; // not supported
- end; // case (dwAction) of ..
- lpIMC := ImmLockIMC(_hIMC);
- if (lpIMC = nil) then Exit;
- Result := True; // **
- case (dwAction) of
- NI_CONTEXTUPDATED:
- begin
- case (dwValue) of
- IMC_SETCONVERSIONMODE:
- begin
- if ((lpIMC.fdwConversion or dwIndex) and IME_CMODE_CHARCODE) <> 0 then
- begin
- // reject CHARCODE
- lpIMC.fdwConversion := lpIMC.fdwConversion and (not IME_CMODE_CHARCODE);
- MessageBeep($FFFFFFFF);
- goto NotifyIMEUnlock; // Break
- end;
- fdwImeMsg := 0;
- if ((lpIMC.fdwConversion or dwIndex) and IME_CMODE_NOCONVERSION) <> 0 then
- begin
- lpIMC.fdwConversion := lpIMC.fdwConversion or IME_CMODE_NATIVE;
- lpIMC.fdwConversion := lpIMC.fdwConversion and not(IME_CMODE_CHARCODE or IME_CMODE_EUDC or IME_CMODE_SYMBOL);
- end;
- if ((lpIMC.fdwConversion or dwIndex) and IME_CMODE_EUDC) <> 0 then
- begin
- lpIMC.fdwConversion := lpIMC.fdwConversion or IME_CMODE_NATIVE;
- lpIMC.fdwConversion := lpIMC.fdwConversion and not(IME_CMODE_CHARCODE or IME_CMODE_NOCONVERSION or IME_CMODE_SYMBOL);
- end;
- if ((lpIMC.fdwConversion or dwIndex) and IME_CMODE_SOFTKBD) <> 0 then
- begin
- fdwImeMsg := MSG_IMN_UPDATE_SOFTKBD;
- end;
- if (lpIMC.fdwConversion or dwIndex) = IME_CMODE_NATIVE then
- begin
- lpIMC.fdwConversion := lpIMC.fdwConversion and not(IME_CMODE_CHARCODE or IME_CMODE_NOCONVERSION or IME_CMODE_EUDC);
- fdwImeMsg := fdwImeMsg or MSG_IMN_UPDATE_SOFTKBD;
- end;
- if (fdwImeMsg <> 0) then GenerateImeMessage(_hIMC, lpIMC, fdwImeMsg);
- if ((lpIMC.fdwConversion or dwIndex) and not(IME_CMODE_FULLSHAPE or IME_CMODE_SOFTKBD)) <> 0 then
- begin
- end else
- begin
- goto NotifyIMEUnlock;
- end;
- CompCancel(_hIMC, lpIMC);
- end;
- IMC_SETOPENSTATUS:
- begin
- if (lpIMC.fdwConversion and IME_CMODE_SOFTKBD) <> 0 then
- begin
- GenerateImeMessage(_hIMC, lpIMC, MSG_IMN_UPDATE_SOFTKBD);
- end;
- CompCancel(_hIMC, lpIMC);
- end;
- end;
- end;
- NI_SELECTCANDIDATESTR:
- begin
- if (lpIMC.fOpen = False) then
- begin
- Result := False;
- end else
- if (lpIMC.fdwConversion and IME_CMODE_NOCONVERSION) <> 0 then
- begin
- Result := False;
- end else
- if (lpIMC.fdwConversion and IME_CMODE_EUDC) <> 0 then
- begin
- Result := False;
- end else
- if (lpIMC.hCandInfo = 0) then
- begin
- Result := False;
- end else
- begin
- lpCandInfo := ImmLockIMCC(lpIMC.hCandInfo);
- if(lpCandInfo = nil) then
- begin
- Result := False;
- end else
- begin
- NotifySelectCand(_hIMC, lpIMC, lpCandInfo, dwIndex, dwValue);
- ImmUnlockIMCC(lpIMC.hCandInfo);
- end;
- end;
- end;
- NI_CHANGECANDIDATELIST:
- begin
- fdwImeMsg := 0;
- fdwImeMsg := fdwImeMsg or MSG_CHANGE_CANDIDATE;
- GenerateImeMessage(_hIMC, lpIMC, fdwImeMsg);
- end;
- NI_SETCANDIDATE_PAGESTART,
- NI_SETCANDIDATE_PAGESIZE:
- begin
- if (dwIndex <> 0) then
- begin
- Result := False;
- end else
- if (lpIMC.fOpen = False) then
- begin
- Result := False;
- end else
- if (lpIMC.fdwConversion and IME_CMODE_NOCONVERSION) <> 0 then
- begin
- Result := False;
- end else
- if (lpIMC.fdwConversion and (IME_CMODE_EUDC or IME_CMODE_SYMBOL)) <> 0 then
- begin
- Result := False;
- end else
- if (lpIMC.hCandInfo = 0) then
- begin
- Result := False;
- end else
- begin
- lpCandInfo := ImmLockIMCC(lpIMC.hCandInfo);
- if (lpCandInfo = nil) then
- begin
- Result := False;
- end else
- begin
- lpCandList := PCandidateList(DWord(lpCandInfo) + lpCandInfo.dwOffset[0]);
- if (dwAction = NI_SETCANDIDATE_PAGESTART) then
- begin
- if (dwValue < lpCandList.dwCount) then
- begin
- lpCandList.dwPageStart := dwValue;
- lpCandList.dwSelection := dwValue;
- end;
- end else
- if (lpCandList.dwCount <> 0) then lpCandList.dwPageSize := dwValue;
- ImmUnlockIMCC(lpIMC.hCandInfo);
- end;
- end;
- end;
- NI_COMPOSITIONSTR:
- begin
- case (dwIndex) of
- CPS_CANCEL:
- CompCancel(_hIMC, lpIMC);
- CPS_COMPLETE:
- begin
- lpImcP := ImmLockIMCC(lpIMC.hPrivate);
- if (lpImcP = nil) then goto NotifyIMEUnlock;
- if (lpImcP.iImeState = CST_INIT) then
- begin
- CompCancel(_hIMC, lpIMC); // can not do any thing
- end else
- if (lpImcP.iImeState = CST_CHOOSE) then
- begin
- lpCompStr := ImmLockIMCC(lpIMC.hCompStr);
- if (lpCompStr = nil) then goto NotifyIMEUnlock;
- lpCandInfo := ImmLockIMCC(lpIMC.hCandInfo);
- if (lpCandInfo <> nil) then
- begin
- lpCandList := PCandidateList(DWord(lpCandInfo) + lpCandInfo.dwOffset[0]);
- SelectOneCand(lpIMC, lpCompStr, lpImcP, lpCandList);
- ImmUnlockIMCC(lpIMC.hCandInfo);
- GenerateMessage(_hIMC, lpIMC, lpImcP);
- end;
- if (lpCompStr <> nil) then ImmUnlockIMCC(lpIMC.hCompStr);
- end else
- if (lpIMC.fdwConversion and (IME_CMODE_NATIVE or IME_CMODE_EUDC or IME_CMODE_SYMBOL) <> IME_CMODE_NATIVE) then
- begin
- CompCancel(_hIMC, lpIMC);
- end else
- if (lpImcP.iImeState = CST_INPUT) then
- begin
- lpCompStr := ImmLockIMCC(lpIMC.hCompStr);
- if (lpCompStr = nil) then goto NotifyIMEUnlock;
- lpGuideLine := ImmLockIMCC(lpIMC.hGuideLine);
- if (lpGuideLine = nil) then
- begin
- ImmUnlockIMCC(lpIMC.hCompStr);
- goto NotifyIMEUnlock;
- end;
- CompWord(Ord(' '), lpIMC, lpCompStr, lpImcP, lpGuideLine);
- if (lpImcP.iImeState = CST_INPUT) then
- begin
- CompCancel(_hIMC, lpIMC);
- end else
- if (lpImcP.iImeState <> CST_CHOOSE) then
- begin
- end else
- begin
- lpCandInfo := ImmLockIMCC(lpIMC.hCandInfo);
- if (lpCandInfo <> nil) then
- begin
- lpCandList := PCandidateList(DWord(lpCandInfo) + lpCandInfo.dwOffset[0]);
- SelectOneCand(lpIMC, lpCompStr, lpImcP, lpCandList);
- ImmUnlockIMCC(lpIMC.hCandInfo);
- end else
- begin
- end;
- end;
- if (lpCompStr <> nil) then ImmUnlockIMCC(lpIMC.hCompStr);
- if (lpGuideLine <> nil) then ImmUnlockIMCC(lpIMC.hGuideLine);
- // don't phrase predition under this case
- if (lpImcP.fdwImeMsg and MSG_ALREADY_OPEN) <> 0 then
- lpImcP.fdwImeMsg := (lpImcP.fdwImeMsg or MSG_CLOSE_CANDIDATE) and not(MSG_OPEN_CANDIDATE or MSG_CHANGE_CANDIDATE)
- else
- lpImcP.fdwImeMsg := lpImcP.fdwImeMsg and not(MSG_CLOSE_CANDIDATE or MSG_OPEN_CANDIDATE);
- GenerateMessage(_hIMC, lpIMC, lpImcP);
- end else
- begin
- CompCancel(_hIMC, lpIMC);
- end;
- ImmUnlockIMCC(lpIMC.hPrivate);
- end;
- end;
- end;
- end;
- NotifyIMEUnlock:
- ImmUnlockIMC(_hIMC);
- end;
- end.