I am trying to create a message box to ask the user if (s)he wants to leave the program when (s)he exits the program. I know how to create a message box, but how to i tell if the user pressed "Yes" or "No"? I've done this in BASIC before, but never in C++. In BASIC, you declare the message box as a string and use an if statement to detirmine if the string is "yes" or "no". Is this similar to C++, or is C++ different?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
On a long term, just go to the Microsoft References for Windows (good old msdn site), and in that desorder there are also a lot of answers.
By the way : did you try the style
MB_YESNO|MB_ICONQUESTION ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am trying to create a message box to ask the user if (s)he wants to leave the program when (s)he exits the program. I know how to create a message box, but how to i tell if the user pressed "Yes" or "No"? I've done this in BASIC before, but never in C++. In BASIC, you declare the message box as a string and use an if statement to detirmine if the string is "yes" or "no". Is this similar to C++, or is C++ different?
Yes there is a return value...
you can use it like:
if(IDYES==MessageBox(.....))
{
..
}
and it will return 0 if it fails to create the box...
Possible return values:
IDABORT
IDCANCEL
IDIGNORE
IDNO
IDOK
IDRETRY
IDYES
On a long term, just go to the Microsoft References for Windows (good old msdn site), and in that desorder there are also a lot of answers.
By the way : did you try the style
MB_YESNO|MB_ICONQUESTION ?