UI Class from IME

Every IME must register its own user interface class (UI) with the system. The UI class provides IME-unique functionality. An IME registers its own class when the IME is attached to the process. That is, when the DllEntry function is called with DLL_PROCESS_ATTACH. The IME must specify the UI class name in a call to the ImeInquire function. The UI class should be registered with CS_IME style so every application can use the UI class. The UI class name (including the null terminator) can be up to 16 TCHAR characters. This limitation may be extended in future version of Windows.

When registering the user interface class, you should specify eight bytes of extra window data. That is, set the cbWndExtra member of the WNDCLASSEX structure to 2 * sizeof(LONG). The extra window data is used by the system.

An IME can register any class and create any window while performing tasks for an application.

The following example shows how to register the IME window class:

BOOL WINAPI DLLEntry (
    HINSTANCE    hInstDLL,
    DWORD        dwFunction,
    LPVOID       lpNot)
{
    switch (dwFunction) {
        case DLL_PROCESS_ATTACH:
            hInst= hInstDLL;
 
            wc.style          = CS_MYCLASSFLAG | CS_IME;
            wc.lpfnWndProc    = MyUIServerWndProc;
            wc.cbClsExtra     = 0;
            wc.cbWndExtra     = 2 * sizeof(LONG);
            wc.hInstance      = hInst;
            wc.hCursor        = LoadCursor( NULL, IDC_ARROW);
            wc.hIcon          = NULL;
            wc.lpszMenuName   = (LPSTR) NULL;
            wc.lpszClassName  = (LPSTR) szUIClassName;
            wc.hbrBackground  = NULL;
 
            if(!RegisterClass((LPWNDCLASS)&wc))
                return FALSE;
 
            wc.style          = CS_MYCLASSFLAG | CS_IME;
            wc.lpfnWndProc    = MyCompStringWndProc;
            wc.cbClsExtra     = 0;
            wc.cbWndExtra     = cbMyWndExtra;
            wc.hInstance      = hInst;
            wc.hCursor        = LoadCursor(NULL, IDC_ARROW);
            wc.hIcon          = NULL;
            wc.lpszMenuName   = (LPSTR) NULL;
            wc.lpszClassName  = (LPSTR) szUICompStringClassName;
            wc.hbrBackground  = NULL;
 
            if(!RegisterClass((LPWNDCLASS)&wc))
                return FALSE;
 
            break;
 
        case DLL_PROCESS_DETACH:
            UnregisterClass(szUIClassName,hInst);
            UnregisterClass(szUICompStringClassName,hInst);
            break;
    }
    return TRUE;
}