点击MessageBox中的确定按键,怎样按键精灵 触发事件件

MessageBox函数_百度百科
清除历史记录关闭
声明:百科词条人人可编辑,词条创建和修改均免费,绝不存在官方及代理商付费代编,请勿上当受骗。
MessageBox函数
本词条缺少名片图,补充相关内容使词条更完整,还能快速升级,赶紧来吧!
MessageBox 函数用于创建、显示并操作一个消息对话框。该对话框包含由调用程序定义的信息和标题,以及预先定义的图标和按钮。
MessageBox函数简介
定义(适用于Visual Basic 6.0):
Declare Function MessageBox Lib &user32& Alias &MessageBoxA& (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long
MessageBox函数参数说明
指定该对话框的所有者窗口。如果该参数为空(0),则该对话框不属于任何窗口(?)。
显示在对话框中的消息。
lpCaption:
在对话框中显示的字符串。如果该参数为空(vbNullString),则使用默认的“错误”作为对话框的标题。
指定显示按钮的数目及形式,使用的图标样式,缺省按钮是什么以及的强制回应等。可以为下列常数之一或某几个数值相加的和。
指定按钮样式:
MB_ABORTRETRYIGNORE
显示 Abort、Retry 及 Ignore 按钮。
只显示 OK 按钮。(默认)
MB_OKCANCEL
显示 OK 及 Cancel 按钮。
MB_RETRYCANCEL
显示 Retry 及 Cancel 按钮。
显示 Yes 及 No 按钮。
MB_YESNOCANCEL
显示 Yes、No 及 Cancel 按钮。
指定图标样式:
MB_ICONEXCLAMATION, MB_ICONWARNING
显示 Warning Message 图标。
MB_ICONINFORMATION, MB_ICONASTERISK
显示 Information Message 图标。
MB_ICONQUESTION
显示 Warning Query 图标。
MB_ICONSTOP, MB_ICONERROR, MB_ICONHAND
显示 Critical Message 图标。
MB_DEFBUTTON1
第一个按钮是。(默认)
MB_DEFBUTTON2
第二个按钮是缺省值。
MB_DEFBUTTON3
第三个按钮是缺省值。
MB_DEFBUTTON4
第四个按钮是缺省值。
指定对话框模式等:
MB_APPLMODAL
应用程序强制返回;应用程序一直被挂起,直到用户对作出响应才继续工作。
MB_SYSTEMMODAL
系统强制返回;全部应用程序都被挂起,直到用户对消息框作出响应才继续工作。
MB_TASKMODAL
MB_DEFAULT_DESKTOP_ONLY
将Help按钮添加到消息框。
文本为右对齐。
MB_RTLREADING
指定文本应为在希伯来和阿拉伯语系统中的从右到左显示。
MB_SETFOREGROUND
指定窗口作为前景窗口。
MB_TOPMOST
MB_SERVICE_NOTIFICATION
MB_SERVICE_NOTIFICATION_NT3X
MB_SERVICE_NOTIFICATION
如果没有足够内存创建消息对话框,则返回0。
如果函数成功运行,则返回下列数值之一:
用户点击了 Abort 按钮。
用户点击了 Cancel 按钮。
用户点击了 Ignore 按钮。
用户点击了 No 按钮。
用户点击了 OK 按钮。
用户点击了 Retry 按钮。
用户点击了 Yes 按钮。
如果对话框显示 Cancel 按钮,则按下 ESC 键与单击 Cancel 按钮的效果相同。
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 &user32& Alias &MessageBoxA& (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long
Parameters:
Identifies the owner window of the message box to be created. If this parameter is NULL, the message box has no owner window.
Points to a null-terminated string containing the message to be displayed.
?lpCaption
Points to a null-terminated string used for the dialog box title. If this parameter is NULL, the default title Error is used.
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.
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.
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.
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 lowercase 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 second 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 user must respond to the message box before continuing work in the window identified by the hWnd parameter. However, the user can move to the windows of other applications and work in those windows.
Depending on the hierarchy of windows in the application, the user 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. Use system-modal message boxes to notify the user of serious, potentially damaging errors that require immediate attention (for example, running out of memory). This flag has no effect on the user's ability to interact with windows other than those 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. Use 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
otherwise, the function fails. A default desktop is one an application runs on after the user has logged on.
Adds a Help button to the message box. Choosing the Help button or pressing F1 generates a Help event.
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 service notifying the user of an event. The function displays a message box on the current active desktop, even if there is no user logged on to the computer.
If this flag is set, 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 services by mapping the old value to the new value in the implementation of MessageBox and . This mapping is only done for executables that have a version number, as set by the linker, less than 4.0.
To build a service that uses 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, use the GetVersionEx function to check the system version. Then when running on Windows NT 3.x, use MB_SERVICE_NOTIFICATION_NT3X; and on Windows NT 4.0, use 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:
Abort button was selected.
Cancel button was selected.
Ignore button was selected.
No button was selected.
OK button was selected.
Retry button was selected.
Yes button was selected.
If a message box has a Cancel button, the function returns the IDCANCEL value if either the ESC key is pressed or the Cancel button is selected. 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(&您按了“确定”\n&);
printf(&您按了“取消”\n&);
清除历史记录关闭[转载]C#里的keydown事件实现方向键触发一个操作
已有 4246 次阅读
|系统分类:|文章来源:转载
KeyDown事件中,任何代码都可以,不过要去判断一下当前是哪个按键触发的这个事件,可以利用参数e去判断,具体的每一个按键对应的键值码我在这里忘记了,可以用MessageBox弹出来看看即可~private void Form1_KeyDown(object sender, KeyEventArgs e)
if(e.KeyCode == Keys.Up)
//你要处理的代码,这里是光标上键的时候执行,只要用e.KeyCode去判断是否存在于枚举Keys中的对应键即可
}枚举Keys中所有成员,都对应了键盘上所有的按键~想按什么按键执行什么代码,完全自己高兴~如果是组合键的话,判断表达式为:if(e.Alt && e.KeyCode == Keys.E)这样就是在按下Alt + E键以后执行~Ctrl键也是如此~KeyDown事件必须是在Form窗体的才行~参考:http://wenwen.soso.com/z/q.htm
转载本文请联系原作者获取授权,同时请注明本文来自朱小栋科学网博客。链接地址:
上一篇:下一篇:
当前推荐数:0
推荐到博客首页
评论 ( 个评论)
扫一扫,分享此博文
作者的其他最新博文
热门博文导读
Powered by
Copyright &如何确定MessageBox哪个按钮被点击_百度知道
如何确定MessageBox哪个按钮被点击
我有更好的答案
解决方案1:Java代码
if (Dialog.YES.equals(be.getButtonClicked().getItemId())) {
Info.display(&&,&您点击了确定按钮&);
解决方案2(官方推荐):Java代码
if (be.getButtonClicked() == chooser.getButtonById(&ok&)) {
Info.display(&&,&您点击了确定按钮!&);
采纳率:73%
为您推荐:
其他类似问题
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
阅读(39321)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
在LOFTER的更多文章
loftPermalink:'',
id:'fks_',
blogTitle:'MessageBox.Show()的各种用法',
blogAbstract:'【函数】 &整型& MessageBox(&字符串& Text, &字符串& Title, &整型& nType,MessageBoxIcon);
【函数说明】 弹出一个消息框。
Text &字符串&,消息框的正文;
Title &字符串&,消息框的标题;
nType &整型&,消息框的类型。
返回值:&整型&,用户在消息框上点击关闭时的选择的按钮。 MessageBoxIcon:对话框上显示的图标样式。
MessageBox(\"消息内容\", \"返回值 确定1\",MessageBoxButtons.OK,MessageBoxIcon.Question); ',
blogTag:'',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:2,
publishTime:1,
permalink:'blog/static/',
commentCount:2,
mainCommentCount:2,
recommendCount:3,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'',
hmcon:'1',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}如何创建 Windows MessageBox 并且确定操作员按下的是哪个按钮?_百度文库
赠送免券下载特权
10W篇文档免费专享
部分付费文档8折起
每天抽奖多种福利
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
如何创建 Windows MessageBox 并且确定操作员按下的是哪个按钮?
阅读已结束,下载本文需要
想免费下载更多文档?
定制HR最喜欢的简历
下载文档到电脑,同时保存到云知识,更方便管理
加入VIP
还剩1页未读,
定制HR最喜欢的简历
你可能喜欢

我要回帖

更多关于 js按键触发事件 的文章

 

随机推荐