-
February 1st, 2008, 02:12 AM
#1
Determine if message box button YES or NO was clicked (MB_YESNO)
I want to know how I can determine if YES or NO was clicked on my message box, my message box is called when you click 'Shutdown' in my application menu,
Code:
(at the top of my code) #define CAPTION_CONFIRM TEXT("Confirm")
MessageBox(hWnd, TEXT("Shutdown, yes or no?"), CAPTION_CONFIRM, MB_YESNO)
How do I determine if yes or no was clicked..
Can you help me with this?
Thanks
-
February 1st, 2008, 04:38 AM
#2
Re: Determine if message box button YES or NO was clicked (MB_YESNO)
MessageBox will return zero if it fails, or one of:
IDABORT Abort button was selected.
IDCANCEL Cancel button was selected.
IDCONTINUE Continue button was selected.
IDIGNORE Ignore button was selected.
IDNO No button was selected.
IDOK OK button was selected.
IDRETRY Retry button was selected.
IDTRYAGAIN Try Again button was selected.
IDYES Yes button was selected.
http://msdn2.microsoft.com/en-us/lib...05(VS.85).aspx
-
February 1st, 2008, 01:35 PM
#3
Re: Determine if message box button YES or NO was clicked (MB_YESNO)
Code example -
Code:
...
if(MessageBox(WindowHandleHere, MessageHere, TitleHere, StylesHere) == IDYES) // or IDNO, depending
{
// If the user clicks yes...
}
...
Just sayin' but I'm 14(I'm telling you this so you know what sort of language to use).
Advice received by a user.
-
February 2nd, 2008, 05:11 AM
#4
Re: Determine if message box button YES or NO was clicked (MB_YESNO)
Thanks to both of you, I was looking for MB_YES or MB_NO :P
Cheers
-
February 2nd, 2008, 01:42 PM
#5
Re: Determine if message box button YES or NO was clicked (MB_YESNO)
Originally Posted by Icyculyr
Thanks to both of you, I was looking for MB_YES or MB_NO :P
Cheers
you mean IDYES or IDNO :P
-
February 2nd, 2008, 07:16 PM
#6
Re: Determine if message box button YES or NO was clicked (MB_YESNO)
No :P, I meant I was previously looking for MB_YES and MB_NO, but now I know it is IDYES IDNO etc..
Ty
-
February 3rd, 2012, 11:51 AM
#7
Re: Determine if message box button YES or NO was clicked (MB_YESNO)
DialogResult result = MessageBox.Show("Message", Choose", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Asterisk);
if (result.Equals(DialogResult.Abort))
labelmsg.Text = "Abort is pressed";
if (result.Equals(DialogResult.Retry))
labelmsg.Text = "Retry is pressed";
if (result.Equals(DialogResult.Ignore))
labelmsg.Text = "Ignore is pressed";
-
February 3rd, 2012, 11:59 AM
#8
Re: Determine if message box button YES or NO was clicked (MB_YESNO)
Dear shikha_kumari!
Please note that:
- This thread is exactly four years old and the problem was resolved exactly four years ago.
- Your code has nothing to do with the C++, so I'd recommend you just to delete your post as an inappropriate on this Forum.
Victor Nijegorodov
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|