static void test_ImmDestroyContext(void) { HIMC imc; DWORD ret, count; INPUTCONTEXT *ic; imc = ImmCreateContext(); count = ImmGetIMCLockCount(imc); ok(count == 0, "expect 0, returned %d\n", count); ic = ImmLockIMC(imc); ok(ic != NULL, "ImmLockIMC failed!\n"); count = ImmGetIMCLockCount(imc); ok(count == 1, "expect 1, returned %d\n", count); ret = ImmDestroyContext(imc); ok(ret == TRUE, "Destroy a locked IMC should success!\n"); ic = ImmLockIMC(imc); todo_wine ok(ic == NULL, "Lock a destroyed IMC should fail!\n"); ret = ImmUnlockIMC(imc); todo_wine ok(ret == FALSE, "Unlock a destroyed IMC should fail!\n"); count = ImmGetIMCLockCount(imc); todo_wine ok(count == 0, "Get lock count of a destroyed IMC should return 0!\n"); SetLastError(0xdeadbeef); ret = ImmDestroyContext(imc); todo_wine ok(ret == FALSE, "Destroy a destroyed IMC should fail!\n"); ret = GetLastError(); todo_wine ok(ret == ERROR_INVALID_HANDLE, "wrong last error %08x!\n", ret); }
static HRESULT WINAPI ActiveIMMApp_CreateContext(IActiveIMMApp* This, HIMC *phIMC) { *phIMC = ImmCreateContext(); if (*phIMC) return S_OK; else return E_FAIL; }
static void test_ImmGetIMCLockCount(void) { HIMC imc; DWORD count, ret, i; INPUTCONTEXT *ic; imc = ImmCreateContext(); count = ImmGetIMCLockCount(imc); ok(count == 0, "expect 0, returned %d\n", count); ic = ImmLockIMC(imc); ok(ic != NULL, "ImmLockIMC failed\n!"); count = ImmGetIMCLockCount(imc); ok(count == 1, "expect 1, returned %d\n", count); ret = ImmUnlockIMC(imc); ok(ret == TRUE, "expect TRUE, ret %d\n", ret); count = ImmGetIMCLockCount(imc); ok(count == 0, "expect 0, returned %d\n", count); ret = ImmUnlockIMC(imc); ok(ret == TRUE, "expect TRUE, ret %d\n", ret); count = ImmGetIMCLockCount(imc); ok(count == 0, "expect 0, returned %d\n", count); for (i = 0; i < GMEM_LOCKCOUNT * 2; i++) { ic = ImmLockIMC(imc); ok(ic != NULL, "ImmLockIMC failed!\n"); } count = ImmGetIMCLockCount(imc); todo_wine ok(count == GMEM_LOCKCOUNT, "expect GMEM_LOCKCOUNT, returned %d\n", count); for (i = 0; i < GMEM_LOCKCOUNT - 1; i++) ImmUnlockIMC(imc); count = ImmGetIMCLockCount(imc); todo_wine ok(count == 1, "expect 1, returned %d\n", count); ImmUnlockIMC(imc); count = ImmGetIMCLockCount(imc); todo_wine ok(count == 0, "expect 0, returned %d\n", count); ImmDestroyContext(imc); }
static void test_ImmAssociateContextEx(void) { HIMC imc; BOOL rc; if (!pImmAssociateContextEx) return; imc = ImmGetContext(hwnd); if (imc) { HIMC retimc, newimc; newimc = ImmCreateContext(); ok(newimc != imc, "handles should not be the same\n"); rc = pImmAssociateContextEx(NULL, NULL, 0); ok(!rc, "ImmAssociateContextEx succeeded\n"); rc = pImmAssociateContextEx(hwnd, NULL, 0); ok(rc, "ImmAssociateContextEx failed\n"); rc = pImmAssociateContextEx(NULL, imc, 0); ok(!rc, "ImmAssociateContextEx succeeded\n"); rc = pImmAssociateContextEx(hwnd, imc, 0); ok(rc, "ImmAssociateContextEx failed\n"); retimc = ImmGetContext(hwnd); ok(retimc == imc, "handles should be the same\n"); ImmReleaseContext(hwnd,retimc); rc = pImmAssociateContextEx(hwnd, newimc, 0); ok(rc, "ImmAssociateContextEx failed\n"); retimc = ImmGetContext(hwnd); ok(retimc == newimc, "handles should be the same\n"); ImmReleaseContext(hwnd,retimc); rc = pImmAssociateContextEx(hwnd, NULL, IACE_DEFAULT); ok(rc, "ImmAssociateContextEx failed\n"); } ImmReleaseContext(hwnd,imc); }
static void test_ImmDefaultHwnd(void) { HIMC imc1, imc2, imc3; HWND def1, def3; HWND hwnd; hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "Wine imm32.dll test", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 240, 120, NULL, NULL, GetModuleHandle(0), NULL); ShowWindow(hwnd, SW_SHOWNORMAL); imc1 = ImmGetContext(hwnd); if (!imc1) { win_skip("IME support not implemented\n"); return; } def1 = ImmGetDefaultIMEWnd(hwnd); imc2 = ImmCreateContext(); ImmSetOpenStatus(imc2, TRUE); imc3 = ImmGetContext(hwnd); def3 = ImmGetDefaultIMEWnd(hwnd); ok(def3 == def1, "Default IME window should not change\n"); ok(imc1 == imc3, "IME context should not change\n"); ImmSetOpenStatus(imc2, FALSE); ImmReleaseContext(hwnd, imc1); ImmReleaseContext(hwnd, imc3); ImmDestroyContext(imc2); DestroyWindow(hwnd); }
BOOL InsertConsole( HWND hWnd, HANDLE hConsole, HWND hWndConsole ) { ULONG i; PCONSOLE_TABLE FocusedConsole; i = 1; do { for (; i < NumberOfConsoleTable; i++) { FocusedConsole = ConsoleTable[i]; if (FocusedConsole == NULL) { FocusedConsole = LocalAlloc(LPTR, sizeof(CONSOLE_TABLE)); if (FocusedConsole == NULL) return FALSE; ConsoleTable[i] = FocusedConsole; } if ((FocusedConsole->hConsole != NULL) && (FocusedConsole->LateRemove)&& (FocusedConsole->Enable)) { RemoveConsoleWorker(hWnd, FocusedConsole); } if (FocusedConsole->hConsole == NULL) { RtlZeroMemory(FocusedConsole, sizeof(CONSOLE_TABLE)); FocusedConsole->lphklList = LocalAlloc(LPTR, sizeof(HKL_TABLE)*HKL_INITIAL_TABLE); if (FocusedConsole->lphklList == NULL) { return FALSE; } RtlZeroMemory(FocusedConsole->lphklList, sizeof(HKL_TABLE)*HKL_INITIAL_TABLE); FocusedConsole->hklListMax = HKL_INITIAL_TABLE ; FocusedConsole->hIMC_Current = ImmCreateContext(); if (FocusedConsole->hIMC_Current == (HIMC)NULL) { LocalFree(FocusedConsole); FocusedConsole = NULL; return FALSE; } FocusedConsole->hIMC_Original = FocusedConsole->hIMC_Current; FocusedConsole->hConsole = hConsole; FocusedConsole->hWndCon = hWndConsole; // FocusedConsole->hklActive = NULL; FocusedConsole->Enable = TRUE; // FocusedConsole->LateRemove = FALSE; // FocusedConsole->fNestCandidate = FALSE; // FocusedConsole->fInComposition = FALSE; // FocusedConsole->fInCandidate = FALSE; FocusedConsole->ScreenBufferSize.X = DEFAULT_TEMP_WIDTH; FocusedConsole->CompAttrColor[0] = DEFAULT_COMP_ENTERED; FocusedConsole->CompAttrColor[1] = DEFAULT_COMP_ALREADY_CONVERTED; FocusedConsole->CompAttrColor[2] = DEFAULT_COMP_CONVERSION; FocusedConsole->CompAttrColor[3] = DEFAULT_COMP_YET_CONVERTED; FocusedConsole->CompAttrColor[4] = DEFAULT_COMP_INPUT_ERROR; FocusedConsole->CompAttrColor[5] = DEFAULT_COMP_INPUT_ERROR; FocusedConsole->CompAttrColor[6] = DEFAULT_COMP_INPUT_ERROR; FocusedConsole->CompAttrColor[7] = DEFAULT_COMP_INPUT_ERROR; GetIMEName(FocusedConsole); return TRUE; } } } while (GrowConsoleTable()); DBGPRINT(("CONIME: Cannot grow Console Table\n")); return FALSE; }
LRESULT CALLBACK CompStrWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HIMC hIMC = NULL; HIMC hOldIMC = NULL; switch (message) { case WM_CREATE: hIMC = ImmCreateContext(); hOldIMC = ImmAssociateContext(hWnd,hIMC); SetWindowLongPtr(hWnd, 0, (LONG_PTR)hOldIMC); fdwProperty = ImmGetProperty(GetKeyboardLayout(0), IGP_PROPERTY); break; case WM_CHAR: HandleChar(hWnd,wParam,lParam); break; case WM_LBUTTONUP: /* fall-through */ case WM_RBUTTONUP: if (hIMC = ImmGetContext(hWnd)) { HMENU hMenu = NULL; InitMenuItemIDTable(); hMenu = CreateImeMenu(hWnd, hIMC, NULL,(message == WM_RBUTTONUP)); if (hMenu) { DWORD dwItemData; DWORD dwPos = (DWORD)GetMessagePos(); int nCmd; nCmd = TrackPopupMenuEx(hMenu, TPM_RETURNCMD | TPM_NONOTIFY | TPM_LEFTBUTTON | TPM_LEFTALIGN | TPM_TOPALIGN, LOWORD(dwPos), HIWORD(dwPos), hWnd, NULL); if (nCmd) { nCmd -= IDM_STARTIMEMENU; dwItemData = FindItemData(nCmd); ImmNotifyIME(hIMC, NI_IMEMENUSELECTED, nCmd, dwItemData); } } EndMenuItemIDTable(); DestroyMenu(hMenu); } break; case WM_IME_SETCONTEXT: if (fShowCand) { lParam &= ~ISC_SHOWUICANDIDATEWINDOW; } if (fdwProperty & IME_PROP_SPECIAL_UI) { // EMPTY } else if (fdwProperty & IME_PROP_AT_CARET) { lParam &= ~ISC_SHOWUICOMPOSITIONWINDOW; } else { // EMPTY } return (DefWindowProc(hWnd, message, wParam, lParam)); case WM_IME_STARTCOMPOSITION: // Normally, we should not call into HandleStartComposition // for IME_PROP_SPECIAL_UI and not IME_PROP_AT_CARET IMEs // we should pass this message to DefWindowProc directly for // this kind of IMEs HandleStartComposition(hWnd,wParam,lParam); // pass this message to DefWindowProc for IME_PROP_SPECIAL_UI // and not IME_PROP_AT_CARET IMEs if (fdwProperty & IME_PROP_SPECIAL_UI) { return (DefWindowProc(hWnd, message, wParam, lParam)); } else if (fdwProperty & IME_PROP_AT_CARET) { // EMPTY } else { return (DefWindowProc(hWnd, message, wParam, lParam)); } break; case WM_IME_ENDCOMPOSITION: // Normally, we should not call into HandleEndComposition // for IME_PROP_SPECIAL_UI and not IME_PROP_AT_CARET IMEs // we should pass this message to DefWindowProc directly for // this kind of IMEs HandleEndComposition(hWnd,wParam,lParam); // pass this message to DefWindowProc for IME_PROP_SPECIAL_UI // and not IME_PROP_AT_CARET IMEs if (fdwProperty & IME_PROP_SPECIAL_UI) { return (DefWindowProc(hWnd, message, wParam, lParam)); } else if (fdwProperty & IME_PROP_AT_CARET) { // EMPTY } else { return (DefWindowProc(hWnd, message, wParam, lParam)); } break; case WM_IME_COMPOSITION: // Normally, we should not call into HandleComposition // for IME_PROP_SPECIAL_UI and not IME_PROP_AT_CARET IMEs // we should pass this message to DefWindowProc directly for // this kind of IMEs HandleComposition(hWnd,wParam,lParam); // pass this message to DefWindowProc for IME_PROP_SPECIAL_UI // and not IME_PROP_AT_CARET IMEs if (fdwProperty & IME_PROP_SPECIAL_UI) { return (DefWindowProc(hWnd, message, wParam, lParam)); } else if (fdwProperty & IME_PROP_AT_CARET) { // EMPTY } else { return (DefWindowProc(hWnd, message, wParam, lParam)); } break; case WM_PAINT: HandlePaint(hWnd,wParam,lParam); break; case WM_IME_NOTIFY: { LRESULT lRet; // Normally, we should not call into HandleNotify // for IME_PROP_SPECIAL_UI and not IME_PROP_AT_CARET IMEs // we should pass this message to DefWindowProc directly for // this kind of IMEs lRet = HandleNotify(hWnd, message, wParam, lParam); // pass this message to DefWindowProc for IME_PROP_SPECIAL_UI // and not IME_PROP_AT_CARET IMEs if (fdwProperty & IME_PROP_SPECIAL_UI) { return (DefWindowProc(hWnd, message, wParam, lParam)); } else if (fdwProperty & IME_PROP_AT_CARET) { // EMPTY } else { return (DefWindowProc(hWnd, message, wParam, lParam)); } return lRet; } case WM_DESTROY: hOldIMC = (HIMC)GetWindowLongPtr(hWnd, 0); hIMC = ImmAssociateContext(hWnd, hOldIMC); ImmDestroyContext(hIMC); break; case WM_INPUTLANGCHANGE: fdwProperty = ImmGetProperty(GetKeyboardLayout(0), IGP_PROPERTY); if (hIMC = ImmGetContext(hWnd)) { CANDIDATEFORM cdf = {0}; if (fdwProperty & IME_PROP_AT_CARET) { cdf.dwIndex = 0; cdf.dwStyle = CFS_CANDIDATEPOS; cdf.ptCurrentPos.x = ptImeUIPos.x; cdf.ptCurrentPos.y = ptImeUIPos.y; ImmSetCandidateWindow(hIMC, &cdf); } else { UINT i; // The candidate position should be decided by a near caret // IME. There are 4 candidate form in the input context for (i = 0; i < 4; i++) { if (!ImmGetCandidateWindow(hIMC, i, &cdf)) { continue; } if (cdf.dwStyle == CFS_DEFAULT) { continue; } cdf.dwStyle = CFS_DEFAULT; ImmSetCandidateWindow(hIMC, &cdf); } } ImmReleaseContext(hWnd, hIMC); } return (DefWindowProc(hWnd, message, wParam, lParam)); default: return (DefWindowProc(hWnd, message, wParam, lParam)); } return 0L; }