Try this one, it displays four different styles messages, maybe you get the idea of how message boxes work. The last one prompts you with a question.
#include <windows.h>
int main(int argc, char* argv[])
{
MessageBox(NULL, "Serious error", "<Message title here>", MB_ICONSTOP|MB_SETFOREGROUND);
MessageBox(NULL, "Warning", "<Message title here>", MB_ICONEXCLAMATION|MB_SETFOREGROUND);
MessageBox(NULL, "Info", "<Message title here>", MB_ICONINFORMATION|MB_SETFOREGROUND);
if(IDYES == MessageBox(NULL, "Click Yes or No",
"<Message title here>",
MB_ICONQUESTION|MB_YESNO|MB_SETFOREGROUND))
{
MessageBox(NULL, "You clicked Yes",
"<Message title here>",
MB_ICONINFORMATION|MB_SETFOREGROUND);
}
else
{
MessageBox(NULL, "You clicked No",
"<Message title here>",
MB_ICONINFORMATION|MB_SETFOREGROUND);
}
return 0;
}
转自:http://www.daniweb.com/software-development/cpp/threads/109791/how-to-display-error-messages