Moving the IME candidate window to desired position doesn't work

thebluetropics 1,046 Reputation points
2023-02-24T14:16:48.69+00:00

I am using IMM (Input Method Manager) to work with IME in my program. Here is my code to move the IME candidate window when the candidate window is about to open:

case WM_IME_NOTIFY: {
    if (wparam == IMN_OPENCANDIDATE) {
        HIMC himc = ImmGetContext(_phwnd);

        CANDIDATEFORM cf;
        cf.dwIndex = 0;
        cf.dwStyle = CFS_FORCE_POSITION;
        cf.ptCurrentPos.x = 100;
        cf.ptCurrentPos.y = 0;

        ImmSetCandidateWindow(himc, &cf);
        ImmReleaseContext(_phwnd, himc);

        return 0;
    }
    return DefWindowProcW(_phwnd, msg, wparam, lparam);
}

This code doesn't work, I don't know why. I think that's because the IME has it's own positioning system and they override it somehow. If so, how do I correctly control the IME window?

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,523 questions
{count} votes