MessageBoxW Function
Signature:
int MessageBoxW(
[in, optional] HWND hWnd,
[in, optional] LPCWSTR lpText,
[in, optional] LPCWSTR lpCaption,
[in] UINT uType
);
Parameters
-
hWnd[in, optional]
A handle to the owner window of the message box to be created. If this parameter isNULL, the message box has no owner window. -
lpText[in, optional]
A null-terminated string that contains the message to be displayed. -
lpCaption[in, optional]
A null-terminated string that specifies the title of the window. If this parameter isNULL, the title is the string "Error". -
uType[in]
A variable of typeUINTthat specifies the content and behavior of the dialog box. This parameter can be a combination of flags from the following message box flags categories.
Return Value
- If the function succeeds, the return value is one of the following menu-defined values:
IDOK,IDCANCEL,IDABORT,IDRETRY,IDIGNORE,IDYES,IDNO,IDCLOSE,IDHELP. - If the function fails, the return value is less than or equal to zero. For extended error information, call
GetLastError.
Remarks
The MessageBoxW function creates, displays, and operates a message box. A message box is a dialog box that displays a specific message to the user and prompts for a response.
The uType parameter determines the buttons displayed, the icon displayed, which control has the keyboard focus, and the modality of the message box. See the Message Box Flags documentation for a complete list of options.
Requirements
Header: winuser.h (include windows.h)
Library: User32.lib
DLL: User32.dll
See Also
Example
This example displays a simple message box with an OK button.
#include <windows.h>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
MessageBoxW(NULL, L"This is a simple message box.", L"My Application", MB_OK | MB_ICONINFORMATION);
return 0;
}