The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: tbohon on April 07, 2011, 09:29:21 PM

Title: Looping
Post by: tbohon on April 07, 2011, 09:29:21 PM
In my never-ending quest for knowledge I've started back a ways in MASM32-land trying to fully understand the basics - I was getting ahead of myself and failing miserably.

Anyway I took the example below (which I've modified with additional MessageBoxes) but when it runs the original MessageBox disappears when my 2nd one comes up and the app ends when I close that one.  How would I keep the app running until I click the window close ('x') button?  I'd thought about using a flag but rapidly got into trouble there as well so thought I'd come here to the gurus.


.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib

.data
MsgBoxCaption db "An example of Cancel,Retry,Continue",0
MsgBoxText db "Hello Message Box!",0

AbortTitle  db "Abort Button Clicked",0
AbortMsg    db "The Abort button was clicked",0

RetryTitle  db "Retry Button Clicked",0
RetryMsg    db "Time to retry again ... ",0

IgnoreTitle db "Ignore Button Clicked",0
IgnoreMsg   db "Ignore WHAT???",0

CancelTitle db "Cancel Button Clicked",0
CancelMsg   db "CANCELLED!!!!!",0

.code
start:
invoke MessageBox,
NULL,
addr MsgBoxText,
addr MsgBoxCaption,
MB_ICONERROR OR MB_ABORTRETRYIGNORE

.IF eax==IDABORT
; Abort was pressed
            invoke MessageBox,
                    NULL,
                    addr AbortMsg,
                    addr AbortTitle,
                    MB_ICONINFORMATION OR MB_OK

.ELSEIF eax==IDRETRY
; Retry was pressed
            invoke MessageBox,
                    NULL,
                    addr RetryMsg,
                    addr RetryTitle,
                    MB_ICONINFORMATION OR MB_OK

      .ELSEIF eax==IDIGNORE
            ; Ignore was pressed
            invoke MessageBox,
                    NULL,
                    addr IgnoreMsg,
                    addr IgnoreTitle,
                    MB_ICONINFORMATION OR MB_OK

.ENDIF

invoke ExitProcess,NULL
end start


Thanks in advance for not laughing me off the net ...  :bg
Title: Re: Looping
Post by: johnsa on April 07, 2011, 09:45:48 PM
This would loop until you click abort... ?
If you mean the close button (X) on the window itself you have that disabled.


.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib

.data
MsgBoxCaption db "An example of Cancel,Retry,Continue",0
MsgBoxText db "Hello Message Box!",0

AbortTitle  db "Abort Button Clicked",0
AbortMsg    db "The Abort button was clicked",0

RetryTitle  db "Retry Button Clicked",0
RetryMsg    db "Time to retry again ... ",0

IgnoreTitle db "Ignore Button Clicked",0
IgnoreMsg   db "Ignore WHAT???",0

CancelTitle db "Cancel Button Clicked",0
CancelMsg   db "CANCELLED!!!!!",0

.code
start:

MessageBoxLoop:

invoke MessageBox,
NULL,
addr MsgBoxText,
addr MsgBoxCaption,
MB_ICONERROR OR MB_ABORTRETRYIGNORE

.IF eax==IDABORT
; Abort was pressed
            invoke MessageBox,
                    NULL,
                    addr AbortMsg,
                    addr AbortTitle,
                    MB_ICONINFORMATION OR MB_OK

.ELSEIF eax==IDRETRY
; Retry was pressed
            invoke MessageBox,
                    NULL,
                    addr RetryMsg,
                    addr RetryTitle,
                    MB_ICONINFORMATION OR MB_OK
jmp messageboxloop
      .ELSEIF eax==IDIGNORE
            ; Ignore was pressed
            invoke MessageBox,
                    NULL,
                    addr IgnoreMsg,
                    addr IgnoreTitle,
                    MB_ICONINFORMATION OR MB_OK
jmp messageboxloop
.ENDIF

invoke ExitProcess,NULL
end start
Title: Re: Looping
Post by: tbohon on April 07, 2011, 10:02:35 PM
 :red

Well I'm embarassed - I was making it TOO hard ... <sigh>

Thanks.