MessageBox函数
MessageBox函数的原文
The MessageBox 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.
Declaration:
Declare Function MessageBox Lib ur32 Alias MessageBoxA (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long
Parameters:
?hWnd
Identifies the owner window of the message box to be created. If this parameter is NULL, the message box has no owner window.
?lpText
Points to a null-terminated string containing the message to be displayed.
?lpCaption
Points to a null-terminated string ud for the dialog box title. If this parameter is NULL, the default title Error is ud.
?uType
Specifies a t 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.
Specify one of the following flags to indicate the buttons contained in the message box:
MB_ABORTRETRYIGNORE
The message box contains three push buttons: Abort, Retry, and Ignore.
MB_OK
The message box contains one push button: OK. This is the default.
MB_OKCANCEL
The message box contains two push buttons: OK and Cancel.
MB_RETRYCANCEL
The message box contains two push buttons: Retry and Cancel.
MB_YESNO
The message box contains two push buttons: Yes and No.
MB_YESNOCANCEL
The message box contains three push buttons: Yes, No, and Cancel.
Specify one of the following flags to display an icon in the message box:
MB_ICONEXCLAMATION,
MB_ICONWARNING
An exclamation-point icon appears in the message box.
MB_ICONINFORMATION, MB_ICONASTERISK
An icon consisting of a lowerca letter i in a circle appears in the message box.
MB_ICONQUESTION
A question-mark icon appears in the message box.
MB_ICONSTOP,
MB_ICONERROR,
MB_ICONHAND
A stop-sign icon appears in the message box.
Specify one of the following flags to indicate the default button:
MB_DEFBUTTON1
The first button is the default button.
MB_DEFBUTTON1 is the default unless MB_DEFBUTTON2, MB_DEFBUTTON3, or MB_DEFBUTTON4 is specified.
MB_DEFBUTTON2
The cond button is the default button.
MB_DEFBUTTON3
The third button is the default button.
MB_DEFBUTTON4
The fourth button is the default button.
Specify one of the following flags to indicate the modality of the dialog box:
MB_APPLMODAL
The ur must respond to the message box before continuing work in the window identified by the hWnd parameter. However, the ur can move to the windows of other applications and work in tho windows.
Depending on the hierarchy of windows in the application, the ur may be able to move to other windows within the application. All child windows of the parent of the message box are automatically disabled, but popup windows are not.
MB_APPLMODAL is the default if neither MB_SYSTEMMODAL nor MB_TASKMODAL is specified.
MB_SYSTEMMODAL
Same as MB_APPLMODAL except that the message box has the WS_EX_TOPMOST style. U system-modal message boxes to notify the ur of rious, potentially damaging errors that require immediate attention (for example, running out of memory). This flag has no effect on the ur's ability to interact with windows other than tho associated with hWnd.
MB_TASKMODAL
Same as MB_APPLMODAL except that all the top-level windows belonging to the current task are disabled if the hWnd parameter is NULL. U this flag when the calling application or library does not have a window handle available but still needs to prevent input to other windows in the current application without suspending other applications.
In addition, you can specify the following flags:
MB_DEFAULT_DESKTOP_ONLY
The desktop currently receiving input must be a default desktop; otherwi, the function fails. A default desktop is one an application runs on after the ur has logged on.
MB_HELP
Adds a Help button to the message box. Choosing the Help button or pressing F1 generates a Help event.
MB_RIGHT
The text is right-justified.
MB_RTLREADING
Displays message and caption text using right-to-left reading order on Hebrew and Arabic systems.
MB_SETFOREGROUND
The message box becomes the foreground window. Internally, Windows calls the SetForegroundWindow function for the message box.
MB_TOPMOST
The message box is created with the WS_EX_TOPMOST window style.
MB_SERVICE_NOTIFICATION
Windows NT only: The caller is a rvice notifying the ur of an event. The function displays a message box on the current active desktop, even if there is no ur logged on to the computer.
If this flag is t, the hWnd parameter must be NULL. This is so the message box can appear on a desktop other than the desktop corresponding to the hWnd.
For Windows NT version 4.0, the value of MB_SERVICE_NOTIFICATION has changed. See WINUSER.H for the old and new values. Windows NT 4.0 provides backward compatibility for pre-existing rvices by mapping the old value to the new value in the implementation of MessageBox and MessageBoxEx. This mapping is only done for executables that have a version number, as t by the linker, less than 4.0.
To build a rvice that us MB_SERVICE_NOTIFICATION, and can run on both Windows NT 3.x and Windows NT 4.0, you have two choices. 1. At link-time, specify a version number less than 4.0; or
2. At link-time, specify version 4.0. At run-time, u the GetVersionEx function to check the system version. Then when running on Windows NT 3.x, u MB_SERVICE_NOTIFICATION_NT3X; and on Windows NT 4.0, u MB_SERVICE_NOTIFICATION.
MB_SERVICE_NOTIFICATION_NT3X
Windows NT only: This value corresponds to the value defined for MB_SERVICE_NOTIFICATION for Windows NT version 3.51.
Return values:
The return value is zero if there is not enough memory to create the message box.
If the function succeeds, the return value is one of the following menu-item values returned by the dialog box:
IDABORT
Abort button was lected.
IDCANCEL
Cancel button was lected.
IDIGNORE
Ignore button was lected.
IDNO
No button was lected.
IDOK
OK button was lected.
IDRETRY
Retry button was lected.
IDYES
Yes button was lected.
If a message box has a Cancel button, the function returns the IDCANCEL value if either the ESC key is presd or the Cancel button is lected. If the message box has no Cancel button, pressing ESC has no effect.
程序示例:
#include <windows.h>
#include <stdio.h>
int main ( int argc , char *argv[] )
{
//调用API函数MessageBox
int nSelect=::MessageBox(NULL,正文:Hello World,标题:MessageBox程序示例,MB_OKCANCEL | MB_ICONINFORMATION | MB_DEFBUTTON1 );
//API函数前加“::”符号,表示这是一个全局的函数,以与c++类的成员函数相区分
if( IDOK == nSelect )
{
printf(您按了“确定”
);
}
el
{
printf(您按了“取消”
);
}
return 0;
}
请问:VB 里面的MessageBox要怎么用,整个函数是什么样的?
messagebox是c语言中的函数吗 如何用
C语言中messagebox的用法
VC++关于messagebox函数的问题
MB_ABORTRETRYIGNORE:消息框含有三个按钮:Abort,Retry和Ignore。
MB_OK:消息框含有一个按钮:OK。这是缺省值。
MB_OKCANCEL:消息框含有两个按钮:OK和Cancel。
MB_RETRYCANCEL:消息框含有两个按钮:Retry和Cancel。
MB_YESNO:消息框含有两个按钮:Yes和No。
MB_YESNOCANCEL:消息框含有三个按钮:Yes,No和Cancel。
指定下列标志中的一个来显示消息框中的图标:标志的含义如下。
MB_ICONEXCLAMATION:
MB_ICONWARNING:一个惊叹号出现在消息框。
MB_ICONINFORMATION:
MB_ICONASTERISK:一个圆圈中小写字母i组成的图标出现在消息框。
MB_ICONOUESTION:一个问题标记图标出现在消息框。
MB_ICONSTOP:
MB_ICONERROR:
MM_ICONHAND:一个停止消息图标出现在消息框。
指定下列标志中的一个来显不缺省的按钮:标志的含义如下。
MB_DEFBUTTON1:第一个按钮为缺省按钮。如果MB_DEFBUTTON2,MB_DEFBUTTON3,MB_DEFBUTTON4没有被指定,则MB_DEFBUTTON1为缺省值。
MB_DEFSUTTON2;第二个按钮为缺省按钮。
MB_DEFBUTTON3:第三个按钮为缺省按钮。
MB_DEFBUTTON4:第四个按钮为缺省按钮。
指定下列标志中的一个来显示对话框的形态:标志的含义如卜。
MB_APPLMODAL:在hwnd参数标识的窗口中继续工作以前,用户一定响应消息框。但是,用户可以移动到其他线程的窗口且在这些窗口中工作。根据应用程序中窗口的层次机构,用户则以移动到线程内的其他窗口。所有母消息框的子窗口自动地失效,但是弹出窗口不是这样。如果既没有指定MB_SYSTEMMODAL也没有指定MB_TASKMOOAL,则MB_APPLMODAL为缺省的。
MB_SYSTEMMODAL:除了消息框有WB_EX_TOPMOST类型,MB_APPLMODAL和WS_EX_TOPMOST一样。用系统模态消息框来改变各种各样的用户,主要的损坏错误需要立即注意(例如,内存溢出)。如果不是那些与hwnd联系的窗口,此标志对用户对窗口的相互联系没有影响。
MB_TASKMODAL:如果参数hwnd为NULL,除了所有属于当前线程高层次的窗口足失效的,MB_TASKMODALL和MB_ApPLMODAL一样。当调用应用程序或库没有一个可以得到的窗口句柄时,使用此标志。但仍需要阻止到调用应用程序甲其他窗口的输入而不是搁置其他线程。
另外,可以指定下列标志。
MB_DEFAULT_DESKTOP_ONLy:接收输入的当前桌面一定是一个缺省桌面。否则,函数调用失败。缺省桌面是一个在用户已经纪录且以后应用程序在此上面运行的桌面。
MB_HELP:把一个Help按钮增加到消息框。选择Help按钮或按F1产生一个Help事件。
MB_RIGHT:文本为右调整。
MB_RTLREADING:用在Hebrew和Arabic系统中从右到左的顺序显示消息和大写文本。
MB_SETFOREGROUND:消息框变为前景窗口。在内部系统为消息个调用SetForegrundWindow函数。
MB_TOPMOSI:消息框用WS_EX_TOPMOST窗口类型来创建MB_SERVICE_NOTIFICATION。
我有本API的大全,你可以查查
本文发布于:2023-02-28 19:42:00,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/zhishi/a/167762955466540.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:messagebox函数.doc
本文 PDF 下载地址:messagebox函数.pdf
留言与评论(共有 0 条评论) |