Hello,
The two following macros don't verify an INVALID_HANDLE_VALUE in the message loop.This is required by Microsoft.
Quote
; --------------------------------------------
; The following two macros must be used as a
; pair and can only be used once in a module.
; Additional code for processing within the
; message loop can be placed between them.
;
; The single parameter passed to both macros
; is the name of the MSG structure and must be
; the same in both macros.
; --------------------------------------------
BeginMessageLoop MACRO mStruct
MessageLoopStart:
invoke GetMessage,ADDR mStruct,NULL,0,0
cmp eax, 0
je MessageLoopExit
ENDM
EndMessageLoop MACRO mStruct
invoke TranslateMessage, ADDR mStruct
invoke DispatchMessage, ADDR mStruct
jmp MessageLoopStart
MessageLoopExit:
ENDM
As a sample , I use a proc that can be used in many case.A minimal change to the macros can be a verify of the INVALID_HANDLE_VALUE
Quote
Boucle_Attente PROC
local msg:MSG
@@:
; make a choice, GetMessage or PeekMessage work the same,just put the ; at the right place
;INVOKE GetMessage, addr msg, NULL, 0, 0
invoke PeekMessage,addr msg, NULL, 0, 0, PM_REMOVE
.if msg.message != WM_QUIT ;
.if eax != INVALID_HANDLE_VALUE ;invalid handle don't go to crash
.if eax != 0 ;For PeekMessage function
;If WM_KEYUP ...,change in WM_COMMAND ,delet the ; if you want it
;invoke TranslateAccelerator,hWnd,Haccel, ADDR msg;
INVOKE TranslateMessage, addr msg ;prend le message
INVOKE DispatchMessageA , addr msg ;envoi les messages aux fenêtres
.endif
jmp @B
.endif
.endif
FindeBoucle_Attente:
mov eax,msg.wParam
ret
Boucle_Attente endp