Visual C++ and MFC Fundamentals Chapter 2: Introduction to MFC
Practical Learning: Using a Message Box
- To display an combination of buttons on the message box, change the InitInstance()
member function as follows: 
BOOL CExerciseApp::InitInstance()
{
::MessageBox(NULL,
"The username you entered is not in our records.\n"
"Do you wish to contact Human Resources?",
"Failed Logon Attempt",
MB_YESNO);return TRUE;
}- Test the application
 
Figure 42: Creating a Message Box............................................................................................
- Close it and return to MSVC
 - To display the message box with an icon, change InitInstance() as follows:
 
BOOL CExerciseApp::InitInstance()
{
CWnd *Msg = new CWnd;Msg->MessageBox("The credentials you entered are not in our records.\n"
"What do you want to do? Click:\n"
"Yes\tto contact Human Resources\n"
"No\tto close the application\n"
"Cancel\tto try again\n",
"Failed Logon Attempt",
MB_YESNOCANCEL | MB_ICONQUESTION);return TRUE;
}- Test the application