News:

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

Looping

Started by tbohon, April 07, 2011, 09:29:21 PM

Previous topic - Next topic

tbohon

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

johnsa

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

tbohon

 :red

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

Thanks.