News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Message-only window

Started by Vortex, February 24, 2017, 06:13:43 AM

Previous topic - Next topic

Vortex

Here is a small message-only window example. The windowless application sets a timer and displays a message box after 5 seconds.

include     MessageOnlyWnd.inc

.data

ClassName   db 'Message',0
message     db 'Click OK to terminate the application',0
title1      db 'Message-only window',0

.data?

wc          WNDCLASSEX <?>
msg         MSG <?>
hInstance   dq ?

.code

start:

    sub     rsp,12*8+8

    invoke  GetModuleHandle,0
    mov     hInstance,rax

    mov     wc.cbSize,SIZEOF WNDCLASSEX
    lea     rcx,WndProc
    mov     wc.lpfnWndProc,rcx
    mov     wc.hInstance,rax
    lea     rcx,ClassName
    mov     wc.lpszClassName,rcx

    invoke  RegisterClassEx,ADDR wc

    xor     rax,rax
   
    invoke  CreateWindowEx,0,ADDR ClassName,0,\
            0,rax,rax,rax,rax,\
            HWND_MESSAGE,rax,hInstance,rax

    .WHILEtrue

        invoke  GetMessage,ADDR msg,NULL,0,0
       
        .BREAKIFeq rax,0

        invoke  TranslateMessage,ADDR msg
        invoke  DispatchMessage,ADDR msg

    .ENDW
   
    invoke  ExitProcess,0


WndProc PROC hWnd:QWORD,uMsg:QWORD,wParam:QWORD,lParam:QWORD

    sub     rsp,4*8

    .ifeq rdx,WM_CREATE

        invoke  SetTimer,rcx,ID_TIMER,5000,ADDR TimerProc
           
    .elseifeq  rdx,WM_DESTROY

        invoke  PostQuitMessage,NULL

    .else

        invoke  DefWindowProc,rcx,rdx,r8,r9     
        ret
       
    .endif
   
    xor     rax,rax
    ret

WndProc ENDP


TimerProc PROC hWnd:QWORD,uMsg:QWORD,idEvent:QWORD,dwTime:QWORD
   
    sub     rsp,4*8
    mov     hWnd,rcx

    invoke  KillTimer,rcx,ID_TIMER
    invoke  MessageBox,0,ADDR message,ADDR title1,MB_OK

    invoke  SendMessage,hWnd,WM_DESTROY,0,0
    ret

TimerProc ENDP

END

hutch--

Works fine here in my Win 10 64.  :t