Windows编程MessageBox函数

API:

int MessageBox(HWND hWnd, LPCTSTRlpText, LPCTSTRlpCaption, UINTuType);

MSDN描述:

This function creates, displays, and operates a message box. The message box contains an application-defined message and title, plus any combination of predefined icons and push buttons.

这个API方法用来创建、显示、操作一个消息框。它包含可设置的消息内容、标题,还可以添加预定义的图标、放置按钮。

参数说明:

MSDN描述:

hWnd

[in] Handle to the owner window of the message box to be created. If this parameter is NULL, the message box has no owner window.

输入参数:指定消息框的父窗口(消息框显示时,父窗口被禁用)。如果这个参数为空,说明消息框没有父窗口,即、没有窗口会因为消息框的出现而被禁用。

参数类型:HWND类型是结构体指针,结构体成员只有一个int。参考MSND的窗口描述符。

lpText

[in] Long pointer to a null-terminated string that contains the message to be displayed.

参数类型: LPCTSTR 字符串指针。

输入参数:指定消息框的消息内容。

lpCaption

[in] Long pointer to a null-terminated string used for the dialog box title. If this parameter is NULL, the default title Error is used.

输入参数:指定消息框的标题。默认值是 Error 或 错误 。

参数类型:LPCTSTR字符串指针。

uType

[in] Specifies a set of bit flags that determine the contents and behavior of the dialog box. This parameter can be a combination of flags from the following groups of flags.

输入参数:指定消息和消息框的显示风格。可按位组合指定多种风格。具体风格参见MSDN。

参数类型:无符号整形。一般传入的是一组用 || 连接的宏。

返回值

             返回0,说明创建、显示消息框失败。

             返回非0,说明消息框操作成功。具体返回值含义如下:

            

Value Description
IDABORT Abort button was selected.用户点击了中止按钮)
IDCANCEL Cancel button or the close button on the title bar was selected.
(用户点击了取消按钮、或者标题栏关闭按钮、或按下ESC键)
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.(用户点击了确定按钮)
来自:http://furzoom.com/ 转载请注明。
原文地址:https://www.cnblogs.com/furzoom/p/7710308.html