home Tech Library Tech Forum
Publisher
 
Creating an MFC Application       
 
 
Message Box in MFC
 
 

 

Message boxes are modal dialogs which once activated needs a user input doesn’t allow to do anything else in the application, which “owns” (parents) the modal dialog. A developer can use message boxes to display, during the running of the program, small information important for the user. They also have a return value which gives the user’s choice when the message box is closed. The call to the MessageBox() function causes a message box to be displayed. The value returned by the MessageBox() function depends on the button selected on the message box by the user.

The first argument to this function is the string (or a pointer to a buffer containing the string) that would be displayed within the message box. The second argument is the string (or a pointer to the string) that would be the caption bar of the message box. The third argument of MessageBox() would consist Button Style and or one of the icon specifiers and or one or two of the modifiers as from the lists below

Return Value:
Zero is returned when there is not enough memory to display the message box; otherwise one of the following values is returned:
IDABORT : Abort button was selected.
IDCANCEL : Cancel button was selected.
IDIGNORE : Ignore button was selected.
IDNO : No button was selected.
IDOK : OK button was selected.
IDRETRY : Retry button was selected.
IDYES : Yes button was selected.

Button Style List:
The indicated buttons will be displayed in the message box if these style is used.
MB_OK “OK” button
MB_YESNO “Yes” and “No” buttons
MB_YESNOCANCEL “Yes,” “No,” and “Cancel” buttons
MB_RETRYCANCEL “Retry” and “Cancel” buttons
MB_OKCANCEL “OK” and “Cancel” buttons
MB_ABORTRETRYIGNORE “Abort,” “Retry,” and “Ignore” buttons

Icon Specifier List:
The corresponding icon for each of the specifier will be displayed in the upper left part of the message box.
MB_ICONINFORMATION Lowercase “i” in a circle
MB_ICONEXCLAMATION Exclamation point in a circle
MB_ICONSTOP Stop sign
MB_ICONQUESTION Question mark

   
  RELATED TOPICS  
Structure of an MFC Application
Creating a Main Window Using MFC
Window Styles
Registering a Window Class
Resource Files in MFC Applications
Menus in MFC Application
Message Maps in MFC Application
Accelerators in MFC Applications
Message Handler Functions
Timer in an MFC Application
Dynamic Menu in MFC
Windows OS Message handlers in CWnd
 


 
           
Home | Profile | Users | Library | Publisher | Tech Forum | News | Contact Us