コード例 #1
0
ファイル: imm32.c プロジェクト: krofna/wine
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);
}
コード例 #2
0
ファイル: activeimmapp.c プロジェクト: hoangduit/reactos
static HRESULT WINAPI ActiveIMMApp_DestroyContext(IActiveIMMApp* This,
        HIMC hIME)
{
    BOOL rc;

    rc = ImmDestroyContext(hIME);
    if (rc)
        return S_OK;
    else
        return E_FAIL;
}
コード例 #3
0
ファイル: conime.c プロジェクト: conioh/os-design
VOID
ExitList(
    HWND hWnd
    )
{
    ULONG i ,j;
    PCONSOLE_TABLE FocusedConsole;

    DBGPRINT(("CONIME:ExitList Processing\n"));
    ImmAssociateContext(hWnd,ghDefaultIMC);

    LockConsoleTable();

    for (i = 1; i < NumberOfConsoleTable; i++) {
        FocusedConsole = ConsoleTable[i];
        if (FocusedConsole != NULL)
        {
            if (FocusedConsole->hConsole != NULL) {
                if (FocusedConsole->Enable) {
                    ImmDestroyContext(FocusedConsole->hIMC_Original);
                    if ( FocusedConsole->lpCompStrMem != NULL) {
                        LocalFree( FocusedConsole->lpCompStrMem );
                        FocusedConsole->lpCompStrMem = NULL;
                    }
                    for (j = 0; j < MAX_LISTCAND; j++){
                        if (FocusedConsole->lpCandListMem[j] != NULL) {
                            LocalFree(FocusedConsole->lpCandListMem[j]);
                            FocusedConsole->lpCandListMem[j] = NULL;
                            FocusedConsole->CandListMemAllocSize[j] = 0;
                        }
                    }
                    if (FocusedConsole->CandSep != NULL) {
                        LocalFree(FocusedConsole->CandSep);
                        FocusedConsole->CandSepAllocSize = 0;
                    }
                    FocusedConsole->Enable = FALSE;
                }
                else
                    FocusedConsole->LateRemove = TRUE;
            }
        }
    }
    LocalFree( ConsoleTable );
    UnlockConsoleTable();

    if (dwConsoleThreadId)
    {
        AttachThreadInput(GetCurrentThreadId(), dwConsoleThreadId, FALSE);
        UnregisterConsoleIME();
        dwConsoleThreadId = 0;
    }
}
コード例 #4
0
ファイル: conime.c プロジェクト: conioh/os-design
BOOL
RemoveConsoleWorker(
    HWND hwnd,
    PCONSOLE_TABLE ConTbl
    )
{
    DWORD j;

    if (ConTbl->Enable) {
        ConTbl->hConsole = NULL;
        ConTbl->ScreenBufferSize.X = 0;
        ConTbl->ConsoleCP = 0;
        ConTbl->ConsoleOutputCP = 0;
        ConTbl->hklActive = 0;

        ImmDestroyContext(ConTbl->hIMC_Original);

        if (ConTbl->lpCompStrMem != NULL){
            LocalFree(ConTbl->lpCompStrMem);
        }
        for (j = 0; j < MAX_LISTCAND; j++){
            if (ConTbl->lpCandListMem[j] != NULL) {
                LocalFree(ConTbl->lpCandListMem[j]);
            }
        }
        if (ConTbl->CandSep != NULL) {
            LocalFree(ConTbl->CandSep);
        }

        if (ConTbl->lphklList != NULL) {
            LocalFree(ConTbl->lphklList) ;
        }

        ConTbl->Enable     = FALSE;
        ConTbl->LateRemove = FALSE;
    }
    else
        ConTbl->LateRemove = TRUE;

#ifdef DEBUG_MODE
    InvalidateRect(hwnd,NULL,TRUE);
#endif
    return TRUE;
}
コード例 #5
0
ファイル: imm32.c プロジェクト: krofna/wine
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);
}
コード例 #6
0
ファイル: imm32.c プロジェクト: krofna/wine
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);
}
コード例 #7
0
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;
}