OS/2 codes: How to support DBCS #4 Process WM_QUERYCONVERTPOS

WM_QUERYCONVERTPOS is sent in order to query a position of a conversion window and a candiate window. However, an application is not aware of IME and not needed to control IME at all.

Let's see a syntax of WM_QUERYCONVERTPOS.

This message is sent by an application to determine whether it is appropriate to begin conversion of DBCS characters.

param1
     PRECTL  pCursorPos  /*  Cursor position. */

param2
     ULONG   ulReserved  /*  Reserved value, should be 0. */

This message may return QCP_CONVERT or QCP_NOCONVERT. If you return QCP_NOCONVERT, then an window does not receive DBCS characters. That is, this has an effect to disable IME. If you return QCP_CONVERT, then an window receives DBCS characters. In this case, [pCursorPos] should be updated. [pCursorPos->xLeft] and [pCursorPos->yBottom] is a bottom-left corner of a conversion window and a upper-left corner of a candidate window. [pCursorPos->xRight] and [pCursorPos-yTop] is a upper-right corner of a conversion window. However, [pCursorPos->xRight] and [pCursorPos->yTop] seems to be ignored. And remember that each positions should be in screen coordinates. For example, if you set [pCursorPos->xLeft] and [pCursorPos->yBottom] to 0, then a conversion window will show at bottom-left corner of screen. If you apply WinMapWindowPoints() to this [pCursorPos], then a conversion window will show at bottom-left corner of screen a window (2016/01/04).

WinMapWindowPoints( hwnd, HWND_DESKTOP, pCursorPos, 1 );

Here is a simple code snippet.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
    case WM_QUERYCONVERTPOS: {
        PRECTL pcp = ( PRECTL )mp1;

        /* Set a position of a bottom-left corner of a conversion window
           and a candiate window. */

        pcp->xLeft = cursor.x;
        pcp->yBottom = cursor.y;

        /* Set a position of a upper-right corner of a conversion window. */
        pcp->xRight = pcp->xLeft + cursor.width;
        pcp->yTop = pcp->yBottom + cursor.height;

        /* Convert a position relative to a window to a position relative to
           screen. */

        WinMapWindowPoints( hwnd, HWND_DESKTOP, pcp, 2 );

        return (MRESULT)QCP_CONVERT;
    }


[mp1] is param1, [cursor] contains a current position of a cursor relative to a window. [hwnd] is a window handle.

Glossary


Conversion window is a window to show characters that users is inputting.

Candidate window is a window to show candidate characters which inputted characters by users will be converted to.


댓글

이 블로그의 인기 게시물

토렌트: < 왕좌의 게임 > 시즌 1 ~ 시즌 8 완결편 마그넷

토렌트: NGC < 코스모스 > 우리말 더빙 전편(1편~13편) 마그넷

토렌트: < 스타워즈 > Ep.1 ~ Ep.6 마그넷