On Tue, 26 Jul 2005 21:26:29 +0900
"Dmitry Timoshkov" <[EMAIL PROTECTED]> wrote:

> "Phil Krylov" <[EMAIL PROTECTED]> wrote:
> 
> > Oh sorry. For some reason I thought that HIWORD(wParam) is used for some
> > other data. Here is a new patch, is it ok?
> 
> Looks good to me, let's see if Alexandre likes it as well.

Still it is not the best. Now, WM_CHARs posted by PostMessageA and
dispatched using GetMessageA work well (are converted back and forth). But
when the message loop uses GetMessageW, these WM_CHARs come to the window
procedure as 4-byte "garbage" (WCHAR which is converted from CP_ACP to
2 WCHARs). In Windows, the window procedure receives unchanged code...

(See attached test).

-- Ph.
#include <stdio.h>

#include <windows.h>

static LRESULT WINAPI MsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    char msg[1000];
    switch (message)
    {
            case WM_CHAR:
                    sprintf(msg, "0x%04x WM_CHAR", LOWORD(wParam));
                    MessageBox(NULL, msg, msg, MB_OK);
                    break;
    }
    return DefWindowProcA(hwnd, message, wParam, lParam);
}

static BOOL RegisterWindowClasses(void)
{
    WNDCLASSA cls;

    cls.style = 0;
    cls.lpfnWndProc = MsgCheckProcA;
    cls.cbClsExtra = 0;
    cls.cbWndExtra = 0;
    cls.hInstance = GetModuleHandleA(0);
    cls.hIcon = 0;
    cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
    cls.hbrBackground = NULL;
    cls.lpszMenuName = NULL;
    cls.lpszClassName = "TestWindowClass";
    if(!RegisterClassA(&cls)) return FALSE;

    return TRUE;
}

int
main(int argc, char **argv)
{
    HWND hwnd;
    MSG msg;
    
    RegisterWindowClasses();
    hwnd = CreateWindowA("TestWindowClass", "caption", WS_OVERLAPPEDWINDOW|WS_VISIBLE,
                    0, 0, 100, 100, NULL, NULL, GetModuleHandleA(0), NULL);
    PostMessageA(hwnd, WM_CHAR, 0xF301, 0);

    while (GetMessageW(&msg, NULL, 0, 0))
            DispatchMessage(&msg);
}

Reply via email to