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 loop error

Started by shankle, December 05, 2012, 02:27:01 PM

Previous topic - Next topic

shankle

In my 1st 64-bit program the following code works just fine.
In my 2nd 64-bit program the following code works just fine.
In my 3rd 64-bit program it produces an error at L2.
Same code in all three programs.
What have I done wrong?????

WinMain:
    FRAME hInst,hPrevInst,CmdLine,CmdShow
   LOCAL wc:WNDCLASSEXA,msg:MSG,hWnd,RR:RECT     

L1:
    INVOKE GetMessageA,addr msg,0,0,0
    test eax,eax              ;see if it is WM_QUIT
    jz >L3                    ;yes
    cmp eax,-1
    je >L2
    INVOKE TranslateMessage,addr msg
    INVOKE DispatchMessageA,addr msg
    jmp L1              ;after message is dealt with, loop back for next one
L2:   
;msg4             db   'in message loop',0
;msg5             db   'error in return value',0
        invoke MessageBox, [hWnd], addr msg4, addr msg5, MB_OK ;true
L3:                     ;message was WM_QUIT
    ret
ENDF

dedndave

could it be a UNICODE issue ?
MessageBoxA

japheth

What MSDN has to say about GetMessage:

Quote
If there is an error, the return value is -1. For example, the function fails if hWnd is an invalid window handle or lpMsg is an invalid pointer. To get extended error information, call GetLastError.

You have no hWnd, but lpMsg can be checked for plausibility. If this gives you no idea, use GetLastError.

shankle

Thanks for your suggestions.
The problem is now solved.
It was caused by the Crimsom Editor and me.
It was putting things in places I did not intend them to go to.