MessageBox (NULL, TEXT ("Hello World"), TEXT ("Hello"), MB_OKCANCEL | MB_ICONEXCLAMATION);
The MessageBox() functon is used to display simple
message
windows and retrieve basic input. This function is highly configurable
with many different
styles.int MessageBox (HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption,
UINT uType);
| Parameter | Purpose |
| HWND hWnd | Handle to the top-level parent window |
| LPCTSTR lpText | Text that appears in the window |
| LPCTSTR lpCaption | Title bar text |
| UINT uType | Flag that specifies the MessageBox appearance (see table below) |
| Flags | Button or Icon |
| For Buttons: | |
| MB_OK | OK |
| MB_OKCANCEL | OK and Cancel |
| MB_RETRYCANCEL | Retry and Cancel |
| MB_YESNO | Yes and No |
| For Icons: | |
| MB_ICONEXCLAMATION, MB_ICONWARNING |
Exclamation point |
| MB_ICONINFORMATION, MB_ICONASTERISK | Lower case i within a circle |
| MB_ICONQUESTION | Question mark |
| MB_YESNO | Yes and No |
| MB_ICONSTOP, MB_ICONERROR MB_ICONHAND |
Exclamation point |
| MB_DEFBUTTON1 | First button |
| MB_DEFBUTTON2 | Second button |
| MB_DEFBUTTON3 | Third button |
| The return value from MessageBox indicates the button pressed by the user. | |
| IDOK | OK button pressed |
| IDYES | Yes button pressed |
| IDNO | No button pressed |
| IDCANCEL | Cancel button pressed or escape key pressed |
![]() MB_OK |
![]() MB_YESNO
|
|
MB_OKCANCEL | MB_ICONINFORMATION |
MB_OKCANCEL | MB_ICONEXCLAMATION |
|
MB_OKCANCEL | MB_ICONSTOP or MB_ICONHAND |
MB_OKCANCEL | MB_ICONQUESTION |