PRB: J/Direct Call to IMM32.ImmSetOpenStatus Fails on Windows 2000


On Windows 2000 with Japanese support enabled, a J/Direct call to the IMM32.ImmSetOpenStatus function always fails, returning false in a Java applet. For example, the following sample code always returns false:
int hImc = IMM32.ImmGetContext(0);boolean b = IMM32.ImmSetOpenStatus(hImc, true);


This problem occurs because the call to the ImmSetOpenStatus function is made from an invalid input context thread. The input context thread should be a browser-created thread; however, in this example, java.lang.Thread calls ImmSetOpenStatus of IMM32.


To ensure that the correct input context thread is used (namely, to get onto the correct thread to own the window), follow these steps:

  1. Call the SetWindowLong function with the GWL_WNDPROC index as follows to create a subclass of the window that specifies the associated window procedure:
    int root = HookProc());,, DllLib.addrOf(root));
  2. Create the HookProc window procedure class so that it extends the class, and make sure to use the CallWindowProc function to call the previously registered window procedure for any messages that HookProc does not process as follows:
    class HookProc extends Callback {...public int callback(int hwnd, int msg, int wparam, int lparam) {         ... hImc = IMM32.ImmGetContext(hwnd);boolean b = IMM32.ImmSetOpenStatus(hImc, true);...         ...return 0;}         ...}


For support information about Visual J++ and the SDK for Java, visit the following Microsoft Web site:

ID articol: 301358 - Ultima examinare: 14 feb. 2017 - Revizie: 1