加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

AfxMessageBox的用法以及一个常见的问题的解决

(2012-04-08 10:32:32)
标签:

afxmessagebox

用法

一个常见的问题

教育

分类: MFC学习笔记MFCLearning

AfxMessageBox的用法

 

int AfxMessageBox(

   LPCTSTR lpszText,

   UINT nType MB_OK,

   UINT nIDHelp 0

);

 

lpszText为显示内容

 

nType 基本类型:

 

MB_ABORTRETRYIGNORE    The message box contains three pushbuttons: Abort, Retry, and Ignore.

MB_OK    The message box contains one pushbutton: OK.

MB_OKCANCEL    The message box contains two pushbuttons: OK and Cancel.

MB_RETRYCANCEL    The message box contains two pushbuttons: Retry and Cancel.

MB_YESNO    The message box contains two pushbuttons: Yes and No.

MB_YESNOCANCEL    The message box contains three pushbuttons: Yes, No, and Cancel.

Return Value

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.


IDCANCELThe 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.


IDYESThe Yes button was selected.     

If message box has 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.  

 

   我在初次学习MFC.net,编写如下代码运行,竟然提示错误

 

error C2665: “AfxMessageBox”: 个重载中没有一个可以转换所有参数类型)。

   代码:

     void CMouseMoveView::OnAppExit()
     {
       // TODO: 在此添加命令处理程序代码
       if(AfxMessageBox("是否真的要退出当前程    序?",MB_YESNO)==IDYES)
       AfxGetMainWnd()->SendMessage(WM_CLOSE)
      }

 

解决办法1: 将第4行改为:if(AfxMessageBox(_T("是否真的要退出当前程序?"),MB_YESNO)==IDYES)

 

解决办法2:选择“项目”菜单->项目属性->配置属性->常规->字符集,改为“未设置”即可。

我觉得我们还是尽量使用方法1来解决这个问题!

 


0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有