📄 notify.cpp
字号:
/*++
Copyright (c) 1990-1999 Microsoft Corporation, All Rights Reserved
Module Name:
notify.c
++*/
#include <windows.h>
#include <imm.h>
#include "imedefs.h"
/**********************************************************************/
/* GenerateMessage() */
/**********************************************************************/
void PASCAL GenerateMessage(
HIMC hIMC,
LPINPUTCONTEXT lpIMC,
LPPRIVCONTEXT lpImcP)
{
if (!hIMC) {
return;
} else if (!lpIMC) {
return;
} else if (!lpImcP) {
return;
} else if (lpImcP->fdwImeMsg & MSG_IN_IMETOASCIIEX) {
return;
} else {
}
lpIMC->dwNumMsgBuf += TranslateImeMessage(NULL, lpIMC, lpImcP);
lpImcP->fdwImeMsg &= (MSG_ALREADY_OPEN|MSG_ALREADY_START);
lpImcP->fdwGcsFlag = 0;
ImmGenerateMessage(hIMC);
return;
}
/**********************************************************************/
/* GenerateImeMessage() */
/**********************************************************************/
void PASCAL GenerateImeMessage(
HIMC hIMC,
LPINPUTCONTEXT lpIMC,
DWORD fdwImeMsg)
{
LPPRIVCONTEXT lpImcP;
lpImcP = (LPPRIVCONTEXT)ImmLockIMCC(lpIMC->hPrivate);
if (!lpImcP) {
return;
}
lpImcP->fdwImeMsg |= fdwImeMsg;
if (fdwImeMsg & MSG_CLOSE_CANDIDATE) {
lpImcP->fdwImeMsg &= ~(MSG_OPEN_CANDIDATE|MSG_CHANGE_CANDIDATE);
} else if (fdwImeMsg & (MSG_OPEN_CANDIDATE|MSG_CHANGE_CANDIDATE)) {
lpImcP->fdwImeMsg &= ~(MSG_CLOSE_CANDIDATE);
}
if (fdwImeMsg & MSG_END_COMPOSITION) {
lpImcP->fdwImeMsg &= ~(MSG_START_COMPOSITION);
} else if (fdwImeMsg & MSG_START_COMPOSITION) {
lpImcP->fdwImeMsg &= ~(MSG_END_COMPOSITION);
}
GenerateMessage(hIMC, lpIMC, lpImcP);
ImmUnlockIMCC(lpIMC->hPrivate);
return;
}
/**********************************************************************/
/* CompCancel() */
/**********************************************************************/
void PASCAL CompCancel(
HIMC hIMC,
LPINPUTCONTEXT lpIMC)
{
LPPRIVCONTEXT lpImcP;
if (!lpIMC->hPrivate) {
return;
}
lpImcP = (LPPRIVCONTEXT)ImmLockIMCC(lpIMC->hPrivate);
if (!lpImcP) {
return;
}
lpImcP->fdwGcsFlag = (DWORD)0;
if (lpImcP->fdwImeMsg & MSG_ALREADY_OPEN) {
CandEscapeKey(lpIMC, lpImcP);
} else if (lpImcP->fdwImeMsg & MSG_ALREADY_START) {
LPCOMPOSITIONSTRING lpCompStr;
lpCompStr = (LPCOMPOSITIONSTRING)ImmLockIMCC(lpIMC->hCompStr);
if (!lpCompStr) {
ImmUnlockIMCC(lpIMC->hCompStr);
ImmUnlockIMCC(lpIMC->hPrivate);
return;
}
CompEscapeKey(lpIMC, lpCompStr, lpImcP);
if (lpCompStr) {
ImmUnlockIMCC(lpIMC->hCompStr);
}
} else {
ImmUnlockIMCC(lpIMC->hPrivate);
return;
}
GenerateMessage(hIMC, lpIMC, lpImcP);
ImmUnlockIMCC(lpIMC->hPrivate);
return;
}
/**********************************************************************/
/* ImeSetCompositionString() */
/* Return Value: */
/* TRUE - successful, FALSE - failure */
/**********************************************************************/
BOOL WINAPI ImeSetCompositionString(
HIMC hIMC,
DWORD dwIndex,
LPVOID lpComp,
DWORD dwCompLen,
LPVOID lpRead,
DWORD dwReadLen)
{
return (FALSE);
}
/**********************************************************************/
/* NotifySelectCand() */
/**********************************************************************/
void PASCAL NotifySelectCand( // app tell IME that one candidate string is
// selected (by mouse or non keyboard action
// - for example sound)
HIMC hIMC,
LPINPUTCONTEXT lpIMC,
LPCANDIDATEINFO lpCandInfo,
DWORD dwIndex,
DWORD dwValue)
{
LPCANDIDATELIST lpCandList;
LPCOMPOSITIONSTRING lpCompStr;
LPPRIVCONTEXT lpImcP;
if (!lpCandInfo) return;
if (dwIndex >= lpCandInfo->dwCount) {
// wanted candidate list is not created yet!
return;
} else if (dwIndex == 0) {
if (lpIMC->fdwConversion & IME_CMODE_CHARCODE) {
return; // not implemented yet
}
}
lpCandList = (LPCANDIDATELIST)
((LPBYTE)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) {
return;
}
// app select this candidate string
lpCandList->dwSelection = dwValue;
lpCompStr = (LPCOMPOSITIONSTRING)ImmLockIMCC(lpIMC->hCompStr);
if(!lpCompStr) return;
lpImcP = (LPPRIVCONTEXT)ImmLockIMCC(lpIMC->hPrivate);
if(!lpCompStr){
ImmUnlockIMCC(lpIMC->hCompStr);
return;
}
// 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);
return;
}
/**********************************************************************/
/* NotifyIME() */
/* Return Value: */
/* TRUE - successful, FALSE - failure */
/**********************************************************************/
BOOL WINAPI NotifyIME(
HIMC hIMC,
DWORD dwAction,
DWORD dwIndex,
DWORD dwValue)
{
LPINPUTCONTEXT lpIMC;
DWORD fdwImeMsg;
BOOL fRet;
if (!hIMC)
{
return (FALSE);
}
lpIMC = (LPINPUTCONTEXT)ImmLockIMC(hIMC);
if (!lpIMC)
{
return (FALSE);
}
fRet = TRUE;
switch (dwAction) {
case NI_CONTEXTUPDATED:
break;
case NI_SELECTCANDIDATESTR:
if (!lpIMC->fOpen) {
fRet = FALSE;
break;
} else if (lpIMC->fdwConversion & IME_CMODE_NOCONVERSION) {
fRet = FALSE;
break;
} else if (lpIMC->fdwConversion & IME_CMODE_EUDC) {
fRet = FALSE;
break;
} else if (!lpIMC->hCandInfo) {
fRet = FALSE;
break;
} else {
LPCANDIDATEINFO lpCandInfo;
lpCandInfo = (LPCANDIDATEINFO)ImmLockIMCC(lpIMC->hCandInfo);
if(!lpCandInfo) {
fRet = FALSE;
break;
}
NotifySelectCand(hIMC, lpIMC, lpCandInfo, dwIndex, dwValue);
ImmUnlockIMCC(lpIMC->hCandInfo);
}
break;
case NI_CHANGECANDIDATELIST:
fdwImeMsg = MSG_CHANGE_CANDIDATE;
GenerateImeMessage(hIMC, lpIMC, fdwImeMsg);
break;
case NI_SETCANDIDATE_PAGESTART:
case NI_SETCANDIDATE_PAGESIZE:
if (dwIndex != 0) {
fRet = FALSE;
break;
} else if (!lpIMC->fOpen) {
fRet = FALSE;
break;
} else if (lpIMC->fdwConversion & IME_CMODE_NOCONVERSION) {
fRet = FALSE;
break;
} else if (lpIMC->fdwConversion & (IME_CMODE_EUDC|IME_CMODE_SYMBOL)) {
fRet = FALSE;
break;
} else if (!lpIMC->hCandInfo) {
fRet = FALSE;
break;
} else {
LPCANDIDATEINFO lpCandInfo;
LPCANDIDATELIST lpCandList;
lpCandInfo = (LPCANDIDATEINFO)ImmLockIMCC(lpIMC->hCandInfo);
if (!lpCandInfo) {
fRet = FALSE;
break;
}
lpCandList = (LPCANDIDATELIST)((LPBYTE)lpCandInfo + lpCandInfo->dwOffset[0]);
if (dwAction == NI_SETCANDIDATE_PAGESTART) {
if (dwValue < lpCandList->dwCount) {
lpCandList->dwPageStart = lpCandList->dwSelection = dwValue;
}
} else {
if (lpCandList->dwCount) {
lpCandList->dwPageSize = dwValue;
}
}
ImmUnlockIMCC(lpIMC->hCandInfo);
}
break;
case NI_COMPOSITIONSTR:
break;
default:
break;
}
ImmUnlockIMC(hIMC);
return (fRet);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -