LRESULT WINAPI UIWndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HIMC hUICurIMC; LPINPUTCONTEXT lpIMC; LPUIEXTRA lpUIExtra; HGLOBAL hUIExtra; LONG lRet = 0L; DebugLog(1,(DebugLogFile,"UIWnd\n")); hUICurIMC = (HIMC)GetWindowLong(hWnd,IMMGWL_IMC); // // Even if there is no current UI. these messages should not be pass to // DefWindowProc(). // if (!hUICurIMC) { switch (message) { case WM_IME_STARTCOMPOSITION: case WM_IME_ENDCOMPOSITION: case WM_IME_COMPOSITION: case WM_IME_NOTIFY: case WM_IME_CONTROL: case WM_IME_COMPOSITIONFULL: case WM_IME_SELECT: case WM_IME_CHAR: return 0L; default: break; } } switch (message) { case WM_CREATE: DebugLog(1,(DebugLogFile,"UIWnd:WM_CREATE\n")); // // Allocate UI's extra memory block. // hUIExtra = GlobalAlloc(GHND,sizeof(UIEXTRA)); lpUIExtra = (LPUIEXTRA)GlobalLock(hUIExtra); lpUIExtra->uiComp.pt.x = -1; lpUIExtra->uiComp.pt.y = -1; CreateCompWindow(hWnd,lpUIExtra); CreateCandWindow(hWnd,lpUIExtra); GlobalUnlock(hUIExtra); SetWindowLong(hWnd,IMMGWL_PRIVATE,(DWORD)hUIExtra); break; case WM_IME_SETCONTEXT: DebugLog(1,(DebugLogFile,"UIWnd:WM_IME_SETCONTEXT\n")); if (wParam) { hUIExtra = (HGLOBAL)GetWindowLong(hWnd,IMMGWL_PRIVATE); lpUIExtra = (LPUIEXTRA)GlobalLock(hUIExtra); if (hUICurIMC) { // // input context was chenged. // if there are the child windows, the diplay have to be // updated. // lpIMC = ImmLockIMC(hUICurIMC); if (lpIMC) { MoveCandWindow(hWnd,lpUIExtra,lpIMC); MoveCompWindow(hWnd,lpUIExtra,lpIMC); } else { HideCandWindow(lpUIExtra); HideCompWindow(lpUIExtra); } ImmUnlockIMC(hUICurIMC); } else // it is NULL input context. { HideCandWindow(lpUIExtra); HideCompWindow(lpUIExtra); } GlobalUnlock(hUIExtra); } break; case WM_IME_STARTCOMPOSITION: DebugLog(1,(DebugLogFile,"UIWnd:WM_IME_STARTCOMPOSITION\n")); // // Start composition! Ready to display the composition string. // break; case WM_IME_COMPOSITION: DebugLog(1,(DebugLogFile,"UIWnd:WM_IME_COMPOSITION\n")); // // Update to display the composition string. // lpIMC = ImmLockIMC(hUICurIMC); hUIExtra = (HGLOBAL)GetWindowLong(hWnd,IMMGWL_PRIVATE); lpUIExtra = (LPUIEXTRA)GlobalLock(hUIExtra); MoveCompWindow(hWnd,lpUIExtra,lpIMC); MoveCandWindow(hWnd,lpUIExtra,lpIMC); GlobalUnlock(hUIExtra); ImmUnlockIMC(hUICurIMC); break; case WM_IME_ENDCOMPOSITION: DebugLog(1,(DebugLogFile,"UIWnd:WM_IME_ENDCOMPOSITION\n")); // // Finish to display the composition string. // hUIExtra = (HGLOBAL)GetWindowLong(hWnd,IMMGWL_PRIVATE); lpUIExtra = (LPUIEXTRA)GlobalLock(hUIExtra); HideCompWindow(lpUIExtra); HideCandWindow(lpUIExtra); GlobalUnlock(hUIExtra); break; case WM_IME_COMPOSITIONFULL: DebugLog(1,(DebugLogFile,"UIWnd:WM_IME_COMPOSITIONFULL\n")); break; case WM_IME_SELECT: DebugLog(1,(DebugLogFile,"UIWnd:WM_IME_SELECT\n")); break; case WM_IME_CONTROL: DebugLog(1,(DebugLogFile,"UIWnd:WM_IME_CONTROL\n")); lRet = ControlHandle(hUICurIMC, hWnd,message,wParam,lParam); break; case WM_IME_NOTIFY: DebugLog(1,(DebugLogFile,"UIWnd:WM_IME_NOTIFY\n")); lRet = NotifyHandle(hUICurIMC, hWnd,message,wParam,lParam); break; case WM_DESTROY: DebugLog(1,(DebugLogFile,"UIWnd:WM_DESTROY\n")); hUIExtra = (HGLOBAL)GetWindowLong(hWnd,IMMGWL_PRIVATE); lpUIExtra = (LPUIEXTRA)GlobalLock(hUIExtra); if (IsWindow(lpUIExtra->uiStatus.hWnd)) DestroyWindow(lpUIExtra->uiStatus.hWnd); if (IsWindow(lpUIExtra->uiCand.hWnd)) DestroyWindow(lpUIExtra->uiCand.hWnd); if (IsWindow(lpUIExtra->uiComp.hWnd)) DestroyWindow(lpUIExtra->uiComp.hWnd); GlobalUnlock(hUIExtra); GlobalFree(hUIExtra); break; case WM_UI_COMPMOVE: hUIExtra = (HGLOBAL)GetWindowLong(hWnd,IMMGWL_PRIVATE); lpUIExtra = (LPUIEXTRA)GlobalLock(hUIExtra); lpUIExtra->uiComp.pt.x = (long)LOWORD(lParam); lpUIExtra->uiComp.pt.y = (long)HIWORD(lParam); GlobalUnlock(hUIExtra); break; default: return DefWindowProc(hWnd,message,wParam,lParam); } return lRet; }
LRESULT WINAPI UIWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HIMC hUICurIMC; LPINPUTCONTEXT lpIMC; LPUIEXTRA lpUIExtra; HGLOBAL hUIExtra; LONG lRet = 0L; hUICurIMC = (HIMC)GetWindowLong(hWnd, IMMGWL_IMC); // // Even if there is no current UI. these messages should not be pass to // DefWindowProc(). // if (!hUICurIMC) { switch (message) { case WM_IME_STARTCOMPOSITION: case WM_IME_ENDCOMPOSITION: case WM_IME_COMPOSITION: case WM_IME_NOTIFY: case WM_IME_CONTROL: case WM_IME_COMPOSITIONFULL: case WM_IME_SELECT: case WM_IME_CHAR: return 0L; default: break; } } switch (message) { case WM_CREATE: TRACE(TEXT("UIWnd:WM_CREATE\n")); hUIExtra = GlobalAlloc(GHND, sizeof(UIEXTRA)); lpUIExtra = (LPUIEXTRA)GlobalLock(hUIExtra); lpUIExtra->uiComp.pt.x = -1; lpUIExtra->uiComp.pt.y = -1; CreateCompWindow(hWnd, lpUIExtra); CreateCandWindow(hWnd, lpUIExtra); GlobalUnlock(hUIExtra); SetWindowLong(hWnd, IMMGWL_PRIVATE, (DWORD)hUIExtra); break; case WM_IME_SETCONTEXT: TRACE(TEXT("UIWnd:WM_IME_SETCONTEXT\n")); if (wParam) { hUIExtra = (HGLOBAL)GetWindowLong(hWnd, IMMGWL_PRIVATE); lpUIExtra = (LPUIEXTRA)GlobalLock(hUIExtra); if (hUICurIMC) { lpIMC = ImmLockIMC(hUICurIMC); if (lpIMC) { MoveCandWindow(hWnd, lpUIExtra, lpIMC); MoveCompWindow(hWnd, lpUIExtra, lpIMC); } else { HideCandWindow(lpUIExtra); HideCompWindow(lpUIExtra); } ImmUnlockIMC(hUICurIMC); } else { HideCandWindow(lpUIExtra); HideCompWindow(lpUIExtra); } GlobalUnlock(hUIExtra); } break; case WM_IME_STARTCOMPOSITION: TRACE(TEXT("UIWnd:WM_IME_STARTCOMPOSITION\n")); break; case WM_IME_COMPOSITION: TRACE(TEXT("...UIWnd:WM_IME_COMPOSITION\n")); lpIMC = ImmLockIMC(hUICurIMC); hUIExtra = (HGLOBAL)GetWindowLong(hWnd, IMMGWL_PRIVATE); lpUIExtra = (LPUIEXTRA)GlobalLock(hUIExtra); MoveCompWindow(hWnd, lpUIExtra, lpIMC); MoveCandWindow(hWnd, lpUIExtra, lpIMC); GlobalUnlock(hUIExtra); lpUIExtra = NULL; ImmUnlockIMC(hUICurIMC); break; case WM_IME_ENDCOMPOSITION: TRACE(TEXT("UIWnd:WM_IME_ENDCOMPOSITION\n")); hUIExtra = (HGLOBAL)GetWindowLong(hWnd, IMMGWL_PRIVATE); lpUIExtra = (LPUIEXTRA)GlobalLock(hUIExtra); HideCompWindow(lpUIExtra); HideCandWindow(lpUIExtra); GlobalUnlock(hUIExtra); break; case WM_IME_COMPOSITIONFULL: TRACE(TEXT("UIWnd:WM_IME_COMPOSITIONFULL\n")); break; case WM_IME_SELECT: TRACE(TEXT("UIWnd:WM_IME_SELECT\n")); break; case WM_IME_CONTROL: TRACE(TEXT("UIWnd:WM_IME_CONTROL\n")); lRet = ControlHandle(hUICurIMC, hWnd,message,wParam,lParam); break; case WM_IME_NOTIFY: TRACE(TEXT("UIWnd:WM_IME_NOTIFY\n")); lRet = NotifyHandle(hUICurIMC, hWnd, message, wParam, lParam); break; case WM_DESTROY: TRACE(TEXT("UIWnd:WM_DESTROY\n")); hUIExtra = (HGLOBAL)GetWindowLong(hWnd, IMMGWL_PRIVATE); lpUIExtra = (LPUIEXTRA)GlobalLock(hUIExtra); if (IsWindow(lpUIExtra->uiStatus.hWnd)) { DestroyWindow(lpUIExtra->uiStatus.hWnd); } if (IsWindow(lpUIExtra->uiCand.hWnd)) { DestroyWindow(lpUIExtra->uiCand.hWnd); } if (IsWindow(lpUIExtra->uiComp.hWnd)) { DestroyWindow(lpUIExtra->uiComp.hWnd); } GlobalUnlock(hUIExtra); GlobalFree(hUIExtra); break; case WM_UI_COMPMOVE: hUIExtra = (HGLOBAL)GetWindowLong(hWnd,IMMGWL_PRIVATE); lpUIExtra = (LPUIEXTRA)GlobalLock(hUIExtra); lpUIExtra->uiComp.pt.x = (long)LOWORD(lParam); lpUIExtra->uiComp.pt.y = (long)HIWORD(lParam); GlobalUnlock(hUIExtra); break; default: return DefWindowProc(hWnd,message,wParam,lParam); } return lRet; }