News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

detect WM_COMMAND in Child Window

Started by RHL, April 20, 2012, 02:35:37 AM

Previous topic - Next topic

RHL

Hi guys!, i have problem with this code, i want detect the WM_COMMAND message of button control, it created with CreateWindowEx function...
I did a subclassing control but I  not know what is bad
please, could you tell me what is bad :)

.386
.model flat,stdcall
option casemap:none
include \masm32\include\masm32rt.inc

WinMain proto :HINSTANCE,:HINSTANCE
WndProc proto :HWND,:UINT,:WPARAM,:LPARAM


.data
classwin1 db "myclass",0
Classwin2 db "#32770",0
win2name db "windows2",0
nmsg db "msg",0
hwin2 dd 0
hButto dd 0
classbutton db "Button",0

hInstance dd 0
hsubclass dd 0

.code
start:
invoke GetModuleHandle, NULL
mov    hInstance,eax

invoke WinMain, hInstance,NULL
invoke ExitProcess,eax

WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
LOCAL hwnd:HWND


mov    wc.cbSize,SIZEOF WNDCLASSEX
mov    wc.style, CS_HREDRAW or CS_VREDRAW
mov    wc.lpfnWndProc, OFFSET WndProc
mov    wc.cbClsExtra,NULL
mov    wc.cbWndExtra,NULL
push  hInstance
pop    wc.hInstance
invoke GetStockObject,WHITE_BRUSH
mov    wc.hbrBackground,eax
mov    wc.lpszMenuName,NULL
mov    wc.lpszClassName,OFFSET classwin1

invoke LoadIcon,hInst,NULL
mov    wc.hIcon,eax
mov  wc.hIconSm,eax

invoke LoadCursor,NULL,IDC_ARROW
mov    wc.hCursor,eax

invoke RegisterClassEx, addr wc
INVOKE CreateWindowEx,NULL,ADDR classwin1,ADDR classwin1,100A2000h,\
CW_USEDEFAULT,CW_USEDEFAULT,270h,0B9h,NULL,NULL,hInst,NULL       
mov    hwnd,eax

invoke ShowWindow, hwnd,SW_SHOWNORMAL
invoke UpdateWindow, hwnd

.WHILE TRUE
invoke GetMessage, ADDR msg,NULL,0,0
.BREAK .if (!eax)
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
.ENDW

mov     eax,msg.wParam
ret
WinMain endp

WndProc2 proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
.if uMsg==WM_COMMAND
invoke MessageBox,0,addr nmsg,addr nmsg,MB_OK      ;  NO DETECT
.endif

invoke CallWindowProc,hsubclass,hWnd,uMsg,wParam,lParam
ret
WndProc2 endp


WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
mov edx,uMsg
.if edx==WM_CREATE
invoke CreateWindowEx,NULL,addr Classwin2,addr win2name,10CA2000h, \
CW_USEDEFAULT,CW_USEDEFAULT,200,200,hWnd,NULL,hInstance,NULL
mov hwin2,eax

invoke CreateWindowEx,NULL,addr classbutton,addr win2name,50010000h, \
20,20,40,40,hwin2,NULL,hInstance,NULL

mov hButto,eax
invoke SetWindowLong,hButto,GWL_WNDPROC,WndProc2
mov hsubclass,eax

.elseif edx==WM_DESTROY
invoke SetWindowLong,hsubclass,GWL_WNDPROC,WndProc2
invoke PostQuitMessage,NULL
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif

xor eax,eax
ret
WndProc endp

end start

MichaelW

Quote from: Microsoft WM_COMMAND documentation
The WM_COMMAND message is sent when the user selects a command item from a menu, when a control sends a notification message to its parent window, or when an accelerator keystroke is translated.

At least normally, child (control) windows do not have a menu, do not serve as a parent window, and do not implement keyboard accelerators.
eschew obfuscation

RHL

ok MichaelW then is not possible :|
I thought was possible, well thanks

RHL

a thing, how do I can "unload" or "kill" a dialog created with CreateWindowEx?
when I press the X for close the window, i cannot, only when I press the X from main window

dedndave

in your dialog proc, you should handle WM_CLOSE
        INVOKE  EndDialog,hWndDlg,NULL

you can close a different window...
        INVOKE  PostMessage,hWindowToClose,WM_SYSCOMMAND,SC_CLOSE,NULL

in the button proc, the WM_LBUTTONDOWN message should work
the system-defined button proc translates that into a WM_COMMAND/BN_CLICKED notification and sends it to the parent
(provided the button is enabled)

RHL


MichaelW

Is this "dialog created with CreateWindowEx" defined in a dialog resource?
eschew obfuscation

RHL

no MichaelW :P, I created the dialog with CreateWIndowEx function :P
the close a dilalog with EndDialog function,it worked , the rest ( capture WM_COMMAND ) I left it  :P

MichaelW

What class name are you using when you create the dialog, and what styles?
eschew obfuscation

RHL

i try do it in several ways :P

class:   "#32770"
name: "any stuff" :P
styles: WS_BORDER or WS_CAPTION or WS_SYSMENU or WS_VISIBLE


      invoke   CreateWindowEx,NULL,addr ""#32770",addr "anystuff",WS_BORDER or WS_CAPTION or WS_SYSMENU or WS_VISIBLE, \
            CW_USEDEFAULT,CW_USEDEFAULT,200,200,hWnd,NULL,hInstance,NULL
      mov      hwin2,eax



EDIT:
something rare happened. when I close the child dialog, it show me the message boxs :|
for example, if I press three time the button ( the button from child window ) then when closse the child window show the message box :|


MichaelW

One of the problems with using the system-defined dialog box class with CreateWindowEx is that you have no control over the window class, so you cannot specify a window procedure that you control. AFAIK what little control you have over the window must be done from the message loop, and the messages that you get there are very limited.

;==============================================================================
; Build as a console app.
;==============================================================================
    include \masm32\include\masm32rt.inc
;==============================================================================
    .data
        hWnd        HWND        0
        hInstance   HINSTANCE   0
        msg         MSG         <>
        wcx         WNDCLASSEX  <>
    .code
;==============================================================================
start:
;==============================================================================
    invoke GetModuleHandle, NULL
    mov hInstance, eax

    invoke GetClassInfoEx, hInstance, chr$("#32770"), ADDR wcx
    printf("%X\n",wcx.lpfnWndProc)

    invoke CreateWindowEx,NULL,
                         chr$("#32770"),
                         chr$("Test"),
                         WS_OVERLAPPEDWINDOW or WS_VISIBLE,
                         CW_USEDEFAULT,
                         CW_USEDEFAULT,
                         200,
                         200,
                         0,
                         0,
                         hInstance,
                         0
    mov hWnd, eax

    invoke CreateWindowEx,NULL,
                         chr$("BUTTON"),
                         chr$("OK"),
                         WS_CHILD or WS_VISIBLE,
                         20,
                         20,
                         60,
                         30,
                         hWnd,
                         0,
                         hInstance,
                         0
  msgLoop:
    invoke GetMessage, ADDR msg, NULL, 0, 0
    .IF eax != 0
        printf("%X\n",msg.message)
        invoke TranslateMessage, addr msg
        invoke DispatchMessage, addr msg
    .ENDIF
    SWITCH msg.message
        CASE WM_COMMAND
            invoke EndDialog, hWnd, 0
            invoke Sleep, 1000
            jmp @F
    ENDSW
    jmp msgLoop
  @@:
    exit
;==============================================================================
end start

eschew obfuscation

dedndave

i see little advantage in creating a dialog box with CreateWindowEx, then subclassing it to get a WndProc   :P
you might be better off to register your own class and create a traditional window with the appropriate style flags

i prefer to create windows and controls using CreateWindowEx   :P
it gives you more precise and detailed control over the features
sometimes, the pre-defined system classes offer exactly what you want - sometimes, they do not

if you are using a pre-defined system class, then going to great lengths to get what you want,
then you may want to consider creating your own window class instead

MichaelW

I had never tried subclassing the window for something like this, but now that I have the subclass procedure appears to receive the full range of messages.


.code
PrintWM proc wm:DWORD, tabs:DWORD
    .WHILE tabs
        printf("\t")
        dec tabs
    .ENDW
    SWITCH wm
        CASE WM_USER
            printf("WM_USER\n")
        CASE WM_NULL
            printf("WM_NULL\n")
        CASE WM_CREATE
            printf("WM_CREATE\n")
        CASE WM_DESTROY
            printf("WM_DESTROY\n")
        CASE WM_MOVE
            printf("WM_MOVE\n")
        CASE WM_SIZE
            printf("WM_SIZE\n")
        CASE WM_ACTIVATE
            printf("WM_ACTIVATE\n")
        CASE WM_SETFOCUS
            printf("WM_SETFOCUS\n")
        CASE WM_KILLFOCUS
            printf("WM_KILLFOCUS\n")
        CASE WM_ENABLE
            printf("WM_ENABLE\n")
        CASE WM_SETREDRAW
            printf("WM_SETREDRAW\n")
        CASE WM_SETTEXT
            printf("WM_SETTEXT\n")
        CASE WM_GETTEXT
            printf("WM_GETTEXT\n")
        CASE WM_GETTEXTLENGTH
            printf("WM_GETTEXTLENGTH\n")
        CASE WM_PAINT
            printf("WM_PAINT\n")
        CASE WM_CLOSE
            printf("WM_CLOSE\n")
        CASE WM_QUERYENDSESSION
            printf("WM_QUERYENDSESSION\n")
        CASE WM_QUIT
            printf("WM_QUIT\n")
        CASE WM_QUERYOPEN
            printf("WM_QUERYOPEN\n")
        CASE WM_ERASEBKGND
            printf("WM_ERASEBKGND\n")
        CASE WM_SYSCOLORCHANGE
            printf("WM_SYSCOLORCHANGE\n")
        CASE WM_ENDSESSION
            printf("WM_ENDSESSION\n")
        CASE WM_SHOWWINDOW
            printf("WM_SHOWWINDOW\n")
        CASE WM_WININICHANGE
            printf("WM_WININICHANGE\n")
        CASE WM_SETTINGCHANGE
            printf("WM_SETTINGCHANGE\n")
        CASE WM_DEVMODECHANGE
            printf("WM_DEVMODECHANGE\n")
        CASE WM_ACTIVATEAPP
            printf("WM_ACTIVATEAPP\n")
        CASE WM_FONTCHANGE
            printf("WM_FONTCHANGE\n")
        CASE WM_TIMECHANGE
            printf("WM_TIMECHANGE\n")
        CASE WM_CANCELMODE
            printf("WM_CANCELMODE\n")
        CASE WM_SETCURSOR
            printf("WM_SETCURSOR\n")
        CASE WM_MOUSEACTIVATE
            printf("WM_MOUSEACTIVATE\n")
        CASE WM_CHILDACTIVATE
            printf("WM_CHILDACTIVATE\n")
        CASE WM_QUEUESYNC
            printf("WM_QUEUESYNC\n")
        CASE WM_GETMINMAXINFO
            printf("WM_GETMINMAXINFO\n")
        CASE WM_PAINTICON
            printf("WM_PAINTICON\n")
        CASE WM_ICONERASEBKGND
            printf("WM_ICONERASEBKGND\n")
        CASE WM_NEXTDLGCTL
            printf("WM_NEXTDLGCTL\n")
        CASE WM_SPOOLERSTATUS
            printf("WM_SPOOLERSTATUS\n")
        CASE WM_DRAWITEM
            printf("WM_DRAWITEM\n")
        CASE WM_MEASUREITEM
            printf("WM_MEASUREITEM\n")
        CASE WM_DELETEITEM
            printf("WM_DELETEITEM\n")
        CASE WM_VKEYTOITEM
            printf("WM_VKEYTOITEM\n")
        CASE WM_CHARTOITEM
            printf("WM_CHARTOITEM\n")
        CASE WM_SETFONT
            printf("WM_SETFONT\n")
        CASE WM_GETFONT
            printf("WM_GETFONT\n")
        CASE WM_SETHOTKEY
            printf("WM_SETHOTKEY\n")
        CASE WM_GETHOTKEY
            printf("WM_GETHOTKEY\n")
        CASE WM_QUERYDRAGICON
            printf("WM_QUERYDRAGICON\n")
        CASE WM_COMPAREITEM
            printf("WM_COMPAREITEM\n")
        CASE WM_GETOBJECT
            printf("WM_GETOBJECT\n")
        CASE WM_COMPACTING
            printf("WM_COMPACTING\n")
        CASE WM_OTHERWINDOWCREATED
            printf("WM_OTHERWINDOWCREATED\n")
        CASE WM_OTHERWINDOWDESTROYED
            printf("WM_OTHERWINDOWDESTROYED\n")
        CASE WM_COMMNOTIFY
            printf("WM_COMMNOTIFY\n")
        CASE WM_WINDOWPOSCHANGING
            printf("WM_WINDOWPOSCHANGING\n")
        CASE WM_WINDOWPOSCHANGED
            printf("WM_WINDOWPOSCHANGED\n")
        CASE WM_POWER
            printf("WM_POWER\n")
        CASE WM_COPYDATA
            printf("WM_COPYDATA\n")
        CASE WM_CANCELJOURNAL
            printf("WM_CANCELJOURNAL\n")
        CASE WM_NOTIFY
            printf("WM_NOTIFY\n")
        CASE WM_INPUTLANGCHANGEREQUEST
            printf("WM_INPUTLANGCHANGEREQUEST\n")
        CASE WM_INPUTLANGCHANGE
            printf("WM_INPUTLANGCHANGE\n")
        CASE WM_TCARD
            printf("WM_TCARD\n")
        CASE WM_HELP
            printf("WM_HELP\n")
        CASE WM_USERCHANGED
            printf("WM_USERCHANGED\n")
        CASE WM_NOTIFYFORMAT
            printf("WM_NOTIFYFORMAT\n")
        CASE WM_CONTEXTMENU
            printf("WM_CONTEXTMENU\n")
        CASE WM_STYLECHANGING
            printf("WM_STYLECHANGING\n")
        CASE WM_STYLECHANGED
            printf("WM_STYLECHANGED\n")
        CASE WM_DISPLAYCHANGE
            printf("WM_DISPLAYCHANGE\n")
        CASE WM_GETICON
            printf("WM_GETICON\n")
        CASE WM_SETICON
            printf("WM_SETICON\n")
        CASE WM_NCCREATE
            printf("WM_NCCREATE\n")
        CASE WM_NCDESTROY
            printf("WM_NCDESTROY\n")
        CASE WM_NCCALCSIZE
            printf("WM_NCCALCSIZE\n")
        CASE WM_NCHITTEST
            printf("WM_NCHITTEST\n")
        CASE WM_NCPAINT
            printf("WM_NCPAINT\n")
        CASE WM_NCACTIVATE
            printf("WM_NCACTIVATE\n")
        CASE WM_GETDLGCODE
            printf("WM_GETDLGCODE\n")
        CASE WM_SYNCPAINT
            printf("WM_SYNCPAINT\n")
        CASE WM_NCMOUSEMOVE
            printf("WM_NCMOUSEMOVE\n")
        CASE WM_NCLBUTTONDOWN
            printf("WM_NCLBUTTONDOWN\n")
        CASE WM_NCLBUTTONUP
            printf("WM_NCLBUTTONUP\n")
        CASE WM_NCLBUTTONDBLCLK
            printf("WM_NCLBUTTONDBLCLK\n")
        CASE WM_NCRBUTTONDOWN
            printf("WM_NCRBUTTONDOWN\n")
        CASE WM_NCRBUTTONUP
            printf("WM_NCRBUTTONUP\n")
        CASE WM_NCRBUTTONDBLCLK
            printf("WM_NCRBUTTONDBLCLK\n")
        CASE WM_NCMBUTTONDOWN
            printf("WM_NCMBUTTONDOWN\n")
        CASE WM_NCMBUTTONUP
            printf("WM_NCMBUTTONUP\n")
        CASE WM_NCMBUTTONDBLCLK
            printf("WM_NCMBUTTONDBLCLK\n")
        CASE WM_KEYFIRST
            printf("WM_KEYFIRST\n")
        CASE WM_KEYDOWN
            printf("WM_KEYDOWN\n")
        CASE WM_KEYUP
            printf("WM_KEYUP\n")
        CASE WM_CHAR
            printf("WM_CHAR\n")
        CASE WM_DEADCHAR
            printf("WM_DEADCHAR\n")
        CASE WM_SYSKEYDOWN
            printf("WM_SYSKEYDOWN\n")
        CASE WM_SYSKEYUP
            printf("WM_SYSKEYUP\n")
        CASE WM_SYSCHAR
            printf("WM_SYSCHAR\n")
        CASE WM_SYSDEADCHAR
            printf("WM_SYSDEADCHAR\n")
        CASE WM_KEYLAST
            printf("WM_KEYLAST\n")
        CASE WM_INITDIALOG
            printf("WM_INITDIALOG\n")
        CASE WM_COMMAND
            printf("WM_COMMAND\n")
        CASE WM_SYSCOMMAND
            printf("WM_SYSCOMMAND\n")
        CASE WM_TIMER
            printf("WM_TIMER\n")
        CASE WM_HSCROLL
            printf("WM_HSCROLL\n")
        CASE WM_VSCROLL
            printf("WM_VSCROLL\n")
        CASE WM_INITMENU
            printf("WM_INITMENU\n")
        CASE WM_INITMENUPOPUP
            printf("WM_INITMENUPOPUP\n")
        CASE WM_MENUSELECT
            printf("WM_MENUSELECT\n")
        CASE WM_MENUCHAR
            printf("WM_MENUCHAR\n")
        CASE WM_ENTERIDLE
            printf("WM_ENTERIDLE\n")
        CASE WM_CTLCOLORMSGBOX
            printf("WM_CTLCOLORMSGBOX\n")
        CASE WM_CTLCOLOREDIT
            printf("WM_CTLCOLOREDIT\n")
        CASE WM_CTLCOLORLISTBOX
            printf("WM_CTLCOLORLISTBOX\n")
        CASE WM_CTLCOLORBTN
            printf("WM_CTLCOLORBTN\n")
        CASE WM_CTLCOLORDLG
            printf("WM_CTLCOLORDLG\n")
        CASE WM_CTLCOLORSCROLLBAR
            printf("WM_CTLCOLORSCROLLBAR\n")
        CASE WM_CTLCOLORSTATIC
            printf("WM_CTLCOLORSTATIC\n")
        CASE WM_MOUSEFIRST
            printf("WM_MOUSEFIRST\n")
        CASE WM_MOUSEMOVE
            printf("WM_MOUSEMOVE\n")
        CASE WM_LBUTTONDOWN
            printf("WM_LBUTTONDOWN\n")
        CASE WM_LBUTTONUP
            printf("WM_LBUTTONUP\n")
        CASE WM_LBUTTONDBLCLK
            printf("WM_LBUTTONDBLCLK\n")
        CASE WM_RBUTTONDOWN
            printf("WM_RBUTTONDOWN\n")
        CASE WM_RBUTTONUP
            printf("WM_RBUTTONUP\n")
        CASE WM_RBUTTONDBLCLK
            printf("WM_RBUTTONDBLCLK\n")
        CASE WM_MBUTTONDOWN
            printf("WM_MBUTTONDOWN\n")
        CASE WM_MBUTTONUP
            printf("WM_MBUTTONUP\n")
        CASE WM_MBUTTONDBLCLK
            printf("WM_MBUTTONDBLCLK\n")
        CASE WM_MOUSELAST
            printf("WM_MOUSELAST\n")
        CASE WM_PARENTNOTIFY
            printf("WM_PARENTNOTIFY\n")
        CASE WM_ENTERMENULOOP
            printf("WM_ENTERMENULOOP\n")
        CASE WM_EXITMENULOOP
            printf("WM_EXITMENULOOP\n")
        CASE WM_MDICREATE
            printf("WM_MDICREATE\n")
        CASE WM_MDIDESTROY
            printf("WM_MDIDESTROY\n")
        CASE WM_MDIACTIVATE
            printf("WM_MDIACTIVATE\n")
        CASE WM_MDIRESTORE
            printf("WM_MDIRESTORE\n")
        CASE WM_MDINEXT
            printf("WM_MDINEXT\n")
        CASE WM_MDIMAXIMIZE
            printf("WM_MDIMAXIMIZE\n")
        CASE WM_MDITILE
            printf("WM_MDITILE\n")
        CASE WM_MDICASCADE
            printf("WM_MDICASCADE\n")
        CASE WM_MDIICONARRANGE
            printf("WM_MDIICONARRANGE\n")
        CASE WM_MDIGETACTIVE
            printf("WM_MDIGETACTIVE\n")
        CASE WM_MDISETMENU
            printf("WM_MDISETMENU\n")
        CASE WM_DROPFILES
            printf("WM_DROPFILES\n")
        CASE WM_MDIREFRESHMENU
            printf("WM_MDIREFRESHMENU\n")
        CASE WM_CUT
            printf("WM_CUT\n")
        CASE WM_COPY
            printf("WM_COPY\n")
        CASE WM_PASTE
            printf("WM_PASTE\n")
        CASE WM_CLEAR
            printf("WM_CLEAR\n")
        CASE WM_UNDO
            printf("WM_UNDO\n")
        CASE WM_RENDERFORMAT
            printf("WM_RENDERFORMAT\n")
        CASE WM_RENDERALLFORMATS
            printf("WM_RENDERALLFORMATS\n")
        CASE WM_DESTROYCLIPBOARD
            printf("WM_DESTROYCLIPBOARD\n")
        CASE WM_DRAWCLIPBOARD
            printf("WM_DRAWCLIPBOARD\n")
        CASE WM_PAINTCLIPBOARD
            printf("WM_PAINTCLIPBOARD\n")
        CASE WM_VSCROLLCLIPBOARD
            printf("WM_VSCROLLCLIPBOARD\n")
        CASE WM_SIZECLIPBOARD
            printf("WM_SIZECLIPBOARD\n")
        CASE WM_ASKCBFORMATNAME
            printf("WM_ASKCBFORMATNAME\n")
        CASE WM_CHANGECBCHAIN
            printf("WM_CHANGECBCHAIN\n")
        CASE WM_HSCROLLCLIPBOARD
            printf("WM_HSCROLLCLIPBOARD\n")
        CASE WM_QUERYNEWPALETTE
            printf("WM_QUERYNEWPALETTE\n")
        CASE WM_PALETTEISCHANGING
            printf("WM_PALETTEISCHANGING\n")
        CASE WM_PALETTECHANGED
            printf("WM_PALETTECHANGED\n")
        CASE WM_HOTKEY
            printf("WM_HOTKEY\n")
        CASE WM_PRINT
            printf("WM_PRINT\n")
        CASE WM_PRINTCLIENT
            printf("WM_PRINTCLIENT\n")
        CASE WM_PENWINFIRST
            printf("WM_PENWINFIRST\n")
        CASE WM_PENWINLAST
            printf("WM_PENWINLAST\n")
    ENDSW
    ret
PrintWM endp


;==============================================================================
; Build as a console app.
;==============================================================================
    include \masm32\include\masm32rt.inc
    include printwm.asm
;==============================================================================
    .data
        hWnd          HWND        0
        hInstance     HINSTANCE   0
        wpOrigWndProc WNDPROC     0
        msg           MSG         <>
        wcx           WNDCLASSEX  <>
    .code
;==============================================================================

SubclassProc proc hwnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM

    invoke PrintWM, uMsg, 1

    invoke CallWindowProc, wpOrigWndProc, hwnd, uMsg, wParam, lParam

    ret

SubclassProc endp

;==============================================================================
start:
;==============================================================================

    invoke GetModuleHandle, NULL
    mov hInstance, eax

    invoke GetClassInfoEx, hInstance, chr$("#32770"), ADDR wcx
    printf("%X\n",wcx.lpfnWndProc)

    invoke CreateWindowEx,NULL,
                         chr$("#32770"),
                         chr$("Test"),
                         WS_OVERLAPPEDWINDOW or WS_VISIBLE,
                         CW_USEDEFAULT,
                         CW_USEDEFAULT,
                         200,
                         200,
                         0,
                         0,
                         hInstance,
                         0
    mov hWnd, eax

    invoke SetWindowLong, hWnd, GWL_WNDPROC, SubclassProc
    mov wpOrigWndProc, eax

    invoke CreateWindowEx,NULL,
                         chr$("BUTTON"),
                         chr$("OK"),
                         WS_CHILD or WS_VISIBLE,
                         20,
                         20,
                         60,
                         30,
                         hWnd,
                         0,
                         hInstance,
                         0
  msgLoop:
    invoke GetMessage, ADDR msg, NULL, 0, 0
    .IF eax != 0
        invoke PrintWM, msg.message, 0
        invoke TranslateMessage, addr msg
        invoke DispatchMessage, addr msg
    .ENDIF
    SWITCH msg.message
        CASE WM_COMMAND
            invoke EndDialog, hWnd, 0
            invoke Sleep, 1000
            jmp @F
    ENDSW
    jmp msgLoop
  @@:
    exit
;==============================================================================
end start

eschew obfuscation


MichaelW

I didn't type all than in, I copied from windows.inc, edited out a few non-WM lines, and used a 12-line FreeBASIC program to convert it to an asm source. Quick and easy once you get used to doing it. I would have used more efficient coding before I would have typed all of that.
eschew obfuscation