ENH: use callback not ifdef for MFC message box errors

This commit is contained in:
Bill Hoffman 2001-10-29 10:41:31 -05:00
parent 539318f587
commit b0e3a2def0
3 changed files with 17 additions and 10 deletions

View File

@ -61,6 +61,17 @@ BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP(); END_MESSAGE_MAP();
void MFCMessageCallback(const char* m, const char* title, bool& nomore)
{
std::string message = m;
message += "\n\n(Press Cancel to suppress any further messages.)";
if(::MessageBox(0, message.c_str(), title,
MB_OKCANCEL) == IDCANCEL)
{
nomore = true;
}
}
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// CMakeSetupDialog dialog // CMakeSetupDialog dialog
@ -68,6 +79,7 @@ CMakeSetupDialog::CMakeSetupDialog(const CMakeCommandLineInfo& cmdInfo,
CWnd* pParent /*=NULL*/) CWnd* pParent /*=NULL*/)
: CDialog(CMakeSetupDialog::IDD, pParent) : CDialog(CMakeSetupDialog::IDD, pParent)
{ {
cmSystemTools::SetErrorCallback(MFCMessageCallback);
m_RegistryKey = "Software\\Kitware\\CMakeSetup\\Settings\\StartPath"; m_RegistryKey = "Software\\Kitware\\CMakeSetup\\Settings\\StartPath";
//{{AFX_DATA_INIT(CMakeSetupDialog) //{{AFX_DATA_INIT(CMakeSetupDialog)

View File

@ -709,18 +709,13 @@ void cmSystemTools::Message(const char* m1, const char *title)
(*s_ErrorCallback)(m1, title, disableMessages); (*s_ErrorCallback)(m1, title, disableMessages);
return; return;
} }
#if defined(_WIN32) && !defined(__CYGWIN__) else
std::string message = m1;
message += "\n\n(Press Cancel to suppress any further messages.)";
if(::MessageBox(0, message.c_str(), title,
MB_OKCANCEL) == IDCANCEL)
{ {
disableMessages = true;
}
#endif
std::cerr << m1 << std::endl; std::cerr << m1 << std::endl;
} }
}
void cmSystemTools::CopyFileIfDifferent(const char* source, void cmSystemTools::CopyFileIfDifferent(const char* source,
const char* destination) const char* destination)