CWnd::MessageBox int MessageBox( LPCTSTR lpszText, LPCTSTR lpszCaption = NULL, UINT nType = MB_OK );void CMyWnd::OnDisplayErrorMessage() { // This displays a message box with the title "Error" // and the message "Help, Something went wrong." // The error icon is displayed in the message box, along with // an OK button. MessageBox("Help, Something went wrong.", "Error", MB_ICONERROR | MB_OK); }
MessageBox("Help, Something went wrong.", "Error", MB_OK);
int MessageBox( LPCTSTR lpszText, LPCTSTR lpszCaption = NULL, UINT nType = MB_OK );void CMyWnd::OnDisplayErrorMessage()
{
// This displays a message box with the title "Error"
// and the message "Help, Something went wrong."
// The error icon is displayed in the message box, along with
// an OK button.
MessageBox("Help, Something went wrong.", "Error",
MB_ICONERROR | MB_OK);
}
str = "你定义的错误信息“;
MessageBox(str,"Error", 48);
你可以看一下MSDN,里面有详细的参数设置
其中括号里应该是一个变量,弹出的对话框就是这个变量的值,这样可以起到验证此变量的值.
还有一个MessageBox("123456789");
这个是用来把括号内的信息作为一个提示显示出来.在TRY{}CATCH{}语句中用的比较多.
点击确定自己就关了的
AfxMessageBox(str);
if( MessageBox( "Help, Something went wrong. ", "Error ",
MB_ICONERROR | MB_OK) == ID_OK) OnClose(); )
MessageBox(_T("消息"));
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 );