AfxMessageBox
来源:互联网 发布:纪录片监守自盗知乎 编辑:程序博客网 时间:2024/04/29 11:00
目录
- AfxMessageBox的函数原型
- AfxMessageBox的返回值
- AfxMessageBox()与MessageBox()的区别
编辑本段AfxMessageBox的函数原型
int AfxMessageBox( LPCTSTR lpszText, UINT nType = MB_OK, UINT nIDHelp = 0 ); int AFXAPI AfxMessageBox( UINT nIDPrompt, UINT nType = MB_OK, UINT nIDHelp = (UINT) –1 ); 在第一种形式中,lpszText表示在消息框内部显示的文本,消息框的标题为应用程序的可执行文件名(如Hello)。在第二种形式中,nIDPrompt为要显示的文本字符串在字符串表中的ID。函数调用时会自动从字符串表中载入字符串并显示在消息框中。nType为消息框中显示的按钮风格和图标风格的组合,可以采用|(或)操作符组合各种风格。 按钮风格 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_ICONINFORMATION 显示一个i图标,表示提示 MB_ICONEXCLAMATION 显示一个惊叹号,表示警告 MB_ICONSTOP 显示手形图标,表示警告或严重错误 MB_ICONQUESTION 显示问号图标,表示疑问 使用时,可以只调用AfxMessageBox(LPCTSTR lpszText);这样默认风格为AfxMessageBox(LPCTSTR lpszText,MB_OK|MB_ICONEXCLAMATION );编辑本段AfxMessageBox的返回值
返回值有8种,如果内存不够,则返回0,否则返回以下值中的一种,分别对应相应的按钮被点击: IDABORT、IDCANCEL、IDIGNORE、IDNO、IDOK 、IDRETRY、IDYES。 MSDN原文: Zero if there is not enough memory to display the message box; otherwise one of the following values is returned: IDABORT The Abort button was selected. IDCANCEL The Cancel button was selected. IDIGNORE The Ignore button was selected. IDNO The No button was selected. IDOK The OK button was selected. IDRETRY The Retry button was selected. IDYES The Yes button was selected. If a message box has a Cancel button, the IDCANCEL value will be returned if either the ESC key is pressed or the Cancel button is selected. If the message box has no Cancel button, pressing the ESC key has no effect.编辑本段AfxMessageBox()与MessageBox()的区别
与AfxMessageBox类似的函数MessageBox,它是CWnd的类成员函数: int MessageBox( LPCTSTR lpszText,LPCTSTR lpszCaption = NULL,UINT nType = MB_OK ); 两个函数的区别:AfxMessageBox比MessageBox简单一些,因为它是一个全局函数所以不需要对应的一个窗口类,但是不能控制消息框标题,常用于调试程序时的内部数据输出或警告;MessageBox比较正式,常用在要提交的应用程序版本中,可以控制标题内容而不必采用含义不明的可执行文件名为标题。 举例: AfxMessageBox("Are you sure?",MB_YESNO|MB_ICONQUESTION); int a = MessageBox(TEXT("是否确认删除?"),TEXT("Warning!!"),4); if(a==6) AfxMessageBox("Yes"); else AfxMessageBox("No"); (其中#define IDYES 6 #define IDNO 7) 主要区别: 1.MessageBox 如果在非CWnd类中使用则是API函数,使用起来非常不便,必须指定标题和样式 否则使用CWnd类的函数,只需一个内容参数就可以了,AfxMessageBox和CWnd类成员函数类似,使用起来很方便,因为是Afx 基于框架的函数 2.MessageBox是模态对话框,你不进行确认时程序不往下运行,它会阻塞你当前的线程为,除非你程序是多线程的程序,否则只有等待模态对话框被确认 3、如果用MFC的话,请尽量使用afxmessagebox,因为这个全局的对话框最安全,也最方便。 但是在WIN32 SDK的情况下只能使用MESSAGEBOX。- AfxMessageBox
- AfxMessageBox
- AfxMessageBox
- AfxMessageBox
- AfxMessageBox
- AfxMessageBox
- AfxMessageBox
- AfxMessageBox问题
- AfxMessageBox函数
- VC++------------AfxMessageBox
- 打造自定义的AfxMessageBox
- 打造自定义的 AfxMessageBox
- AfxMessageBox的问题
- AfxMessageBox字符问题
- 打造自定义的 AfxMessageBox
- AfxMessageBox()与MessageBox()
- AfxMessageBox和MessageBox区别
- AfxMessageBox字符问题
- 无锡新区
- 无锡新区新洲生活广场
- 【面试笔试-php 】百度2012年5月校园招聘
- MongoDB学习笔记(六) MongoDB索引用法和效率分析
- 《深入java虚拟机》学习笔记(第五章 java虚拟机)
- AfxMessageBox
- 调整百度地图中的logo和缩放按钮
- AS3事件机制浅析
- IE下javascript的console方法
- Ubuntu11.04中文输入法的安装(IBus-pinyin
- android Toast大全(五种情形)建立属于你自己的Toast
- SQLServer链接服务器
- android apk反编译打包签名
- VC项目配置基础 VC6.0-VC2005