Paste: my-window doesnt receive messages?

Author: erikc
Mode: factor
Date: Sun, 17 Jan 2010 10:18:58
Plain Text |
: my-wndproc ( -- object )
    LRESULT { HWND UINT WPARAM LPARAM } "stdcall" [
        pick windows-message-name name>> print flush
        DefWindowProc
    ] alien-callback ;
: my-window ( -- hwnd )
    [let
        "My Window" utf16n malloc-string &free :> name-ptr
        WNDCLASSEX <struct> f GetModuleHandle name-ptr pick
        GetClassInfoEx 0 = [
            WNDCLASSEX heap-size >>cbSize
            CS_HREDRAW CS_VREDRAW bitor >>style
            my-wndproc >>lpfnWndProc
            0 >>cbClsExtra
            0 >>cbWndExtra
            f GetModuleHandle >>hInstance
            f GetModuleHandle "fraptor" utf16n string>alien LoadIcon >>hIcon
            f IDC_ARROW LoadCursor >>hCursor
            name-ptr >>lpszClassName
            RegisterClassEx win32-error=0/f
        ] [ drop ] if
        name-ptr name-ptr { WS_CAPTION WS_BORDER WS_THICKFRAME WS_SYSMENU } flags
        CW_USEDEFAULT 0 CW_USEDEFAULT 0 f f f GetModuleHandle f
        CreateWindow dup win32-error=0/f dup SW_SHOW ShowWindow drop
    ] ;

New Annotation

Summary:
Author:
Mode:
Body: