Partial IME Support

IME-aware applications can create their own IME windows, as shown below, instead of relying on the system default.

hIMEWnd = CreateWindowEx(
"IME", // IME class
NULL, // no window title
WS_DISABLED | WS_POPUP, // disabled window
0, 0, 0, 0, // no need to set size
hWnd, // parent window
(int)NULL,
(HINSTACE)GetWindowLong(hWnd,GWL_HINSTANCE),
NULL);

Applications with partial IME support can use this application IME window to control certain IME behavior. For example, by calling the function ImmIsUIMessage, an application can pass messages related to the IME's user interface to the application IME window, where the application can process them. The following code would appear in the application IME window's window procedure:

HIMC hIMC;
LPVOID lpBufResult;
COMPOSITIONFORM cf;
DWORD dwBufLen;
if (ImmIsUIMessage(hIMEWnd, uMsg, wParam, lParam) == TRUE)
{
switch(uMsg)
{
case WM_IME_COMPOSITION:
if (lParam & GCS_RESULTSTR)
{
hIMC = ImmGetContext(hWnd);
ImmGetCompositionString(hIMC, GCS_RESULTSTR,
lpBufResult, dwBufLen);
ImmReleaseContext(hWnd, hIMC);
}
break;
}
return 0;
}

The same window procedure could call SendMessage either to reposition the status, composition, or candidate windows, or to open or close the status window.

SendMessage(hIMEWnd, WM_IME_CONTROL,
IMC_SETCOMPOSITIONWINDOW, &cf);

Other API functions that allow the application to change window positions or properties are ImmSetCandidateWindow, ImmSetCompositionFont, ImmSetCompositionString, ImmSetCompositionWindow, and ImmSetStatusWindowPos. Applications that contain partial support for IMEs can use these functions to set the style and the position of the IME user interface windows, but the IME DLL is still responsible for drawing them—the general appearance of the IME's user interface remains unchanged.