News:

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

About Message Box

Started by G`HOST, September 28, 2005, 06:45:01 PM

Previous topic - Next topic

G`HOST

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

diablo2oo2

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


hutch--

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.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

G`HOST

THANX diablo2oo2 and Hutch  i wil improve. :dance:

diablo2oo2

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