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 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.
我在初次学习MFC.net时,编写如下代码运行,竟然提示错误
(error C2665: “AfxMessageBox”: 2 个重载中没有一个可以转换所有参数类型)。
代码:
1 void CMouseMoveView::OnAppExit()
2 {
3 // TODO: 在此添加命令处理程序代码
4 if(AfxMessageBox("是否真的要退出当前程
序?",MB_YESNO)==IDYES) 5 AfxGetMainWnd()->SendMessage(WM_CLOSE);
6 }
解决办法1: 将第4行改为:if(AfxMessageBox(_T("是否真的要退出当前程序?"),MB_YESNO)==IDYES)
解决办法2:选择“项目”菜单->项目属性->配置属性->常规->字符集,改为“未设置”即可。
我觉得我们还是尽量使用方法1来解决这个问题!
|