Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Visual C++ and MFC Fundamentals Chapter 2: Introduction to MFC


"Failed Logon Attempt");

return TRUE;
}


  1. Test the application and return to MSVC


2.3.6 Message Box Options............................................................................


The uType argument is used to provide some additional options to the message box. First,
it is used to display one or a few buttons. The buttons depend on the value specified for
the argument. If this argument is not specified, the message box displays (only) OK.
Otherwise, you can display a message box with a combination of selected buttons.

To display one or more buttons, the uType argument uses a constant value that controls
what button(s) to display. The values and their buttons can be specified as follows:

Constant Buttons

MB_OK (^)
MB_OKCANCEL (^)
MB_ABORTRETRYIGNORE (^)
MB_YESNOCANCEL (^)
MB_YESNO
MB_RETRYCANCEL
MB_HELP
Here is an example:
BOOL Whatever()
{
MessageBox("Due to an unknown internal error, this application will now close.\n"
"Do you want to save the file before closing?",
"Application Warning",
MB_YESNO);
}
Figure 40 : A Message Box with Various Buttons
Besides the buttons, the message box can also display an icon that accompanies the
message. Each icon is displayed by specifying a constant integer. The values and their
buttons are as follows:
Value Icon Suited when

Free download pdf