如何解决消息框没有出现,但铃声响了
我有一个使用 Visual Studio 2008 编写的 C++ MFC 应用程序。我遇到了数据库错误。发生这种情况时,会引发异常类的实例并调用其 ReportError()
方法。 ReportError()
是一个调用 ::MessageBox()
的简单方法。 MessageBox()
当然应该响铃并显示消息。我收到了铃铛,但没有收到消息框。
数据库工作是在从我的 OnInitDialog()
事件处理程序方法调用的方法中完成的。
BOOL CDeploymentDisplayDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon,TRUE); // Set big icon
SetIcon(m_hIcon,FALSE); // Set small icon
// TODO: Add extra initialization here
deploymentControl.SetConnectionString((LPCTSTR)m_connectionString);
return TRUE; // return TRUE unless you set the focus to a control
}
SetConnectionString()
方法初始化多个 ADORecordset
对象并从每个对象中读取第一条记录。其中之一是引发异常。发生这种情况时,会创建一个 CCDBException
类型的对象并调用其 ReportError()
方法。方法如下:
void CCDBException::ReportError(CCOMString prefixLine)
{
CCOMString message;
message << prefixLine << ENDL << (LPCTSTR)m_strErrorString;
// ::MessageBox(NULL,message,_T("Database Error"),MB_OK | MB_ICONERROR | MB_SYSTEMMODAL);
AfxMessageBox(message);
}
从 ::MessageBox()
更改为 AfxMessageBox()
没有效果。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。