Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hello Word In a MessagBox - Help returning value 1

Status
Not open for further replies.

Trope

Programmer
May 14, 2001
110
0
0
US
Ok, I finally wrote my first successful ASM program, which is below.

My question is this - how do I find out what button ( yes/no/cancel ) the user pressed? Where is this information stored? According to the Win32API:

If the function succeeds, the return value is one of the following menu-item values returned by the dialog box:

Value Meaning
IDABORT Abort button was selected.
IDCANCEL Cancel button was selected.
IDIGNORE Ignore button was selected.
IDNO No button was selected.
IDOK OK button was selected.
IDRETRY Retry button was selected.
IDYES Yes button was selected.

If a message box has a Cancel button, the function returns the IDCANCEL value if either the ESC key is pressed or the Cancel button is selected. If the message box has no Cancel button, pressing ESC has no effect.

How do I have another message box come up and tell me what I chose?

Thanks in advance. As you can see, I am really new at this - yesterday to be exact.

Regards,
Trope

Code:
Here is my code so far:

.386
.model flat, stdcall
option casemap:none

    include \masm32\include\windows.inc
    include \masm32\include\user32.inc
    include \masm32\include\kernel32.inc
    include \masm32\include\gdi32.inc

    includelib \masm32\lib\user32.lib
    includelib \masm32\lib\kernel32.lib
    includelib \masm32\lib\gdi32.lib

.data
MsgCaption      db "My Window Caption",0
MsgBoxText      db "My First Program!",0

.code
start:
	invoke MessageBox, NULL,addr MsgBoxText, addr MsgCaption, MB_YESNOCANCEL

	invoke ExitProcess,NULL
end start
 
Hi Trope,

The return value is in EAX. So the code is:

.If (eax == IDABORT)
; Do something
.endif

Hope it helps

-- AirCon --
 
Perfect, worked great. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top