×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Hello Word In a MessagBox - Help returning value

Hello Word In a MessagBox - Help returning value

Hello Word In a MessagBox - Help returning value

(OP)
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


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

RE: Hello Word In a MessagBox - Help returning value

Hi Trope,

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

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

Hope it helps

-- AirCon --

RE: Hello Word In a MessagBox - Help returning value

(OP)
Perfect, worked great. Thanks

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close