From 7071e88fdeeaa146c8e72894c6eae58f438f2690 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 6 Mar 2018 16:17:32 +0300 Subject: PSN_WIZFINISH: new WM_NOTIFY event to be called when one of the options tabs is changed --- src/mir_app/src/options.cpp | 35 ++++++++++++++++++++++++++++++++--- src/mir_core/src/CCtrlHyperlink.cpp | 2 +- src/mir_core/src/CDlgBase.cpp | 13 ++++++++++--- 3 files changed, 43 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/mir_app/src/options.cpp b/src/mir_app/src/options.cpp index 62a549b9bc..a9fe26c40a 100644 --- a/src/mir_app/src/options.cpp +++ b/src/mir_app/src/options.cpp @@ -289,6 +289,16 @@ struct OptionsPageData : public MZeroedObject } }; +static int CompareOPD(const OptionsPageData *p1, const OptionsPageData *p2) +{ + int res = mir_wstrcmp(p1->ptszGroup, p2->ptszGroup); + if (!res) + res = mir_wstrcmp(p1->ptszTitle, p2->ptszTitle); + if (!res) + res = mir_wstrcmp(p1->ptszTab, p2->ptszTab); + return res; +} + ///////////////////////////////////////////////////////////////////////////////////////// // Options dialog @@ -812,13 +822,12 @@ public: virtual void OnApply() override { - PSHNOTIFY pshn; m_btnApply.Disable(); SetFocus(m_pageTree.GetHwnd()); OptionsPageData *opd = getCurrent(); if (opd != nullptr) { - pshn.hdr.idFrom = 0; + PSHNOTIFY pshn = {}; pshn.lParam = IDC_APPLY; pshn.hdr.code = PSN_KILLACTIVE; pshn.hdr.hwndFrom = opd->getHwnd(); @@ -826,10 +835,16 @@ public: return; } + LIST arChanged(10, CompareOPD); + + PSHNOTIFY pshn = {}; pshn.hdr.code = PSN_APPLY; for (int i = 0; i < m_arOpd.getCount(); i++) { OptionsPageData *p = m_arOpd[i]; - if (p->getHwnd() == nullptr || !p->changed) continue; + if (p->getHwnd() == nullptr || !p->changed) + continue; + + arChanged.insert(p); p->changed = 0; pshn.hdr.hwndFrom = p->getHwnd(); if (SendMessage(p->getHwnd(), WM_NOTIFY, 0, (LPARAM)&pshn) == PSNRET_INVALID_NOCHANGEPAGE) { @@ -843,6 +858,20 @@ public: return; } } + + pshn.hdr.code = PSN_WIZFINISH; + for (int i = 0; i < arChanged.getCount(); i++) { + OptionsPageData *p = arChanged[i]; + if (p->ptszTab == nullptr) + continue; + + // calculate last changed tab + OptionsPageData *p2 = arChanged[i+1]; + if (p2 != nullptr && !mir_wstrcmp(p->ptszTitle, p2->ptszTitle) && !mir_wstrcmp(p->ptszGroup, p2->ptszGroup)) + continue; + + SendMessage(p->pDialog->GetHwnd(), WM_NOTIFY, 0, (LPARAM)&pshn); + } } void btnApply_Click(CCtrlButton*) diff --git a/src/mir_core/src/CCtrlHyperlink.cpp b/src/mir_core/src/CCtrlHyperlink.cpp index fb0ab7f7ae..4b0499479d 100644 --- a/src/mir_core/src/CCtrlHyperlink.cpp +++ b/src/mir_core/src/CCtrlHyperlink.cpp @@ -32,7 +32,7 @@ CCtrlHyperlink::CCtrlHyperlink(CDlgBase* wnd, int idCtrl, const char* url) OnClick = Callback(this, &CCtrlHyperlink::Default_OnClick); } -BOOL CCtrlHyperlink::OnCommand(HWND, WORD, WORD idCode) +BOOL CCtrlHyperlink::OnCommand(HWND, WORD, WORD) { OnClick(this); return FALSE; diff --git a/src/mir_core/src/CDlgBase.cpp b/src/mir_core/src/CDlgBase.cpp index dc938f1fc4..3fb76249bc 100644 --- a/src/mir_core/src/CDlgBase.cpp +++ b/src/mir_core/src/CDlgBase.cpp @@ -247,7 +247,8 @@ INT_PTR CDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) int idCtrl = wParam; NMHDR *pnmh = (NMHDR *)lParam; if (pnmh->idFrom == 0) { - if (pnmh->code == PSN_APPLY) { + switch (pnmh->code) { + case PSN_APPLY: if (LPPSHNOTIFY(lParam)->lParam != 3) // IDC_APPLY m_bExiting = true; @@ -255,10 +256,16 @@ INT_PTR CDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) NotifyControls(&CCtrlBase::OnApply); if (m_lresult) OnApply(); - } - else if (pnmh->code == PSN_RESET) { + break; + + case PSN_RESET: NotifyControls(&CCtrlBase::OnReset); OnReset(); + break; + + case PSN_WIZFINISH: + m_OnFinishWizard(this); + break; } } -- cgit v1.2.3