Is this the correct way to do it .I am just a noob ::) and have just started win32 ASM
.DATA?
ErrorMessage DWORD ?
invoke MessageBox,hWnd,ADDR PexitBoxTxt,ADDR PexitBoxCap,MB_YESNO
mov errorMessage,eax
.IF errorMessage==IDYES
invoke DestroyWindow,hWnd
.ENDIF
did you try to compile it? dont understand why you ask...
only one or two things i would mention is that you can skip the var "errormessage"
just:
.if eax==IDYES
...
.endif
also i like to use chr$ macro
invoke MessageBox,hWnd,chr$("some text"),chr$("more text here"),MB_YESNO
Ghost,
What you are doing looks OK and its good sense to learn the manual code before you try out the higher level stuff that MASM32 supports. If you are happy with the results and it works as expected, you can try out some of the higher level stuff.
cmp rv(MessageBox,hWnd,"Message Text","Caption",MB_YESNO), IDYES
jne @F
invoke DestroyWindow,hWnd
@@:
This code does exactly the same thing but its a bit more compact. If you fully expanded it, it would look someting like this,
push MB_YESNO
push OFFSET caption
push OFFSET Text
push hWnd
call MessageBox
cmp eax, IDYES
jne @F
push hWnd
call DestroyWindow
@@:
The important thing is to understand what you are doing with the code and once you feel comfortable with it you can start using more compact and more easily readable forms.
THANX diablo2oo2 and Hutch i wil improve. :dance:
Quotecmp rv(MessageBox,hWnd,"Message Text","Caption",MB_YESNO), IDYES
jne @F
invoke DestroyWindow,hWnd
@@:
thanks hutch, i didnt know the rv macro before. its also nice that it can be used with the .if macro...
i like it more than the jumps (the code look has a better structure and is easy to read)
.if rv(MessageBox,hWnd,"Message Text","Caption",MB_YESNO) == IDYES
invoke DestroyWindow,hWnd
.endif