From 540e667a9fdae2213756c164185e4d7f78f33e2b Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Mon, 4 Sep 2017 20:47:26 +0100 Subject: [PATCH] frmMain: Close all windows when opening preferences --- source/frmMain.cpp | 32 ++++++++++++++++++++++++++++++++ source/frmMain.h | 1 + 2 files changed, 33 insertions(+) diff --git a/source/frmMain.cpp b/source/frmMain.cpp index 63f0015..aeffdba 100644 --- a/source/frmMain.cpp +++ b/source/frmMain.cpp @@ -477,6 +477,13 @@ void frmMain::ShowAboutWindow( wxCommandEvent& event ) void frmMain::OpenPreferences( wxCommandEvent& event) { + // Close all windows first. + + if (CloseAllWindows() == false) + { + return; + } + // Open the preferences window. ReloadAccounts = FALSE; @@ -3192,4 +3199,29 @@ void frmMain::ResetContactInfo(){ htmContactData->SetPage(EmptyPage); AccCtrl->SetValue(""); +} + +bool frmMain::CloseAllWindows() +{ + // Attempt to close all windows. + + if (WindowListPointersMenu.size() == 0) + { + return true; + } + + if (wxMessageBox(_("Before preforming the action, all windows that are open will need to close. Do you wish to continue?"), _("Close All Windowss"), wxYES_NO) == wxYES) + { + for(std::map::iterator windowIter = WindowListPointers.begin(); + windowIter != WindowListPointers.end(); windowIter++) + { + wxWindow *windowPointer = static_cast(windowIter->second); + windowPointer->Close(); + } + return true; + } + else + { + return false; + } } \ No newline at end of file diff --git a/source/frmMain.h b/source/frmMain.h index ae5c3d0..b9e564b 100644 --- a/source/frmMain.h +++ b/source/frmMain.h @@ -287,6 +287,7 @@ class frmMain : public frmMainADT #else void UpdateSSLAccountStatus(int AccountID, int SSLStatus, SSLCertCollectionString SSLCertInc); #endif + bool CloseAllWindows(); DECLARE_EVENT_TABLE() //// end generated class members -- 2.39.5