From b0e3a2def0c20f20e4cbcf0ff03017777dc1a896 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Mon, 29 Oct 2001 10:41:31 -0500 Subject: [PATCH] ENH: use callback not ifdef for MFC message box errors --- Source/FLTKDialog/CMakeSetupGUIImplementation.cxx | 4 ++-- Source/MFCDialog/CMakeSetupDialog.cpp | 12 ++++++++++++ Source/cmSystemTools.cxx | 11 +++-------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx b/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx index dd02b567e..6fb3f9979 100644 --- a/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx +++ b/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx @@ -17,9 +17,9 @@ void FLTKMessageCallback(const char* message, const char* title, bool& nomore) int ok = fl_ask(message, "Press cancel to suppress any further messages."); if(!ok) - { + { nomore = true; - } + } } /** diff --git a/Source/MFCDialog/CMakeSetupDialog.cpp b/Source/MFCDialog/CMakeSetupDialog.cpp index 3f1fb8f9d..11da2ca77 100644 --- a/Source/MFCDialog/CMakeSetupDialog.cpp +++ b/Source/MFCDialog/CMakeSetupDialog.cpp @@ -61,6 +61,17 @@ BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) 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 @@ -68,6 +79,7 @@ CMakeSetupDialog::CMakeSetupDialog(const CMakeCommandLineInfo& cmdInfo, CWnd* pParent /*=NULL*/) : CDialog(CMakeSetupDialog::IDD, pParent) { + cmSystemTools::SetErrorCallback(MFCMessageCallback); m_RegistryKey = "Software\\Kitware\\CMakeSetup\\Settings\\StartPath"; //{{AFX_DATA_INIT(CMakeSetupDialog) diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 577c8f0d1..a99c5efd8 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -709,16 +709,11 @@ void cmSystemTools::Message(const char* m1, const char *title) (*s_ErrorCallback)(m1, title, disableMessages); return; } -#if defined(_WIN32) && !defined(__CYGWIN__) - std::string message = m1; - message += "\n\n(Press Cancel to suppress any further messages.)"; - if(::MessageBox(0, message.c_str(), title, - MB_OKCANCEL) == IDCANCEL) + else { - disableMessages = true; + std::cerr << m1 << std::endl; } -#endif - std::cerr << m1 << std::endl; + }