From b2c91edc9646daa331de71d589e4fec6bdef4945 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 11 Jul 2018 17:09:17 +0300 Subject: GUI change: - methods OnInitDialog, OnApply & OnClose of CDlgBase now return true if successful. return of false prevents a dialog from being loaded or left respectively; - massive code cleaning considering the 'virtual' attribute of overridden methods; - also fixes #1476 (Don't close "Create new account" window if user not set account name) --- src/core/stdautoaway/src/options.cpp | 6 +- src/core/stdmsg/src/chat_options.cpp | 20 ++- src/core/stdmsg/src/chat_window.cpp | 3 +- src/core/stdmsg/src/msgdialog.cpp | 3 +- src/core/stdmsg/src/msgoptions.cpp | 26 ++-- src/core/stdmsg/src/msgs.h | 4 +- src/core/stdmsg/src/stdafx.h | 8 +- src/core/stdmsg/src/tabs.cpp | 5 +- src/mir_app/src/addcontact.cpp | 3 +- src/mir_app/src/auth.cpp | 14 +- src/mir_app/src/colorchooser.cpp | 8 +- src/mir_app/src/contacts.cpp | 6 +- src/mir_app/src/db_ini.cpp | 271 ++++++++++++++++------------------- src/mir_app/src/ei_options.cpp | 8 +- src/mir_app/src/help.cpp | 5 +- src/mir_app/src/lpopts.cpp | 12 +- src/mir_app/src/menu_options.cpp | 8 +- src/mir_app/src/meta_addto.cpp | 67 ++++----- src/mir_app/src/meta_options.cpp | 6 +- src/mir_app/src/mir_app.def | 2 +- src/mir_app/src/mir_app64.def | 2 +- src/mir_app/src/miranda.cpp | 67 ++++----- src/mir_app/src/options.cpp | 16 ++- src/mir_app/src/pluginopts.cpp | 8 +- src/mir_app/src/profilemanager.cpp | 24 ++-- src/mir_app/src/proto_internal.cpp | 60 ++++---- src/mir_app/src/proto_opts.cpp | 24 ++-- src/mir_app/src/proto_order.cpp | 6 +- src/mir_app/src/proto_ui.cpp | 6 +- src/mir_app/src/skin2opts.cpp | 22 +-- src/mir_app/src/srmm_base.cpp | 3 +- src/mir_app/src/srmm_toolbar.cpp | 8 +- src/mir_core/src/CCtrlBase.cpp | 3 +- src/mir_core/src/CCtrlCheck.cpp | 3 +- src/mir_core/src/CCtrlCombo.cpp | 3 +- src/mir_core/src/CCtrlEdit.cpp | 3 +- src/mir_core/src/CCtrlPages.cpp | 12 +- src/mir_core/src/CCtrlSpin.cpp | 3 +- src/mir_core/src/CDlgBase.cpp | 78 +++++++--- src/mir_core/src/mir_core.def | 20 +-- src/mir_core/src/mir_core64.def | 20 +-- 41 files changed, 466 insertions(+), 410 deletions(-) (limited to 'src') diff --git a/src/core/stdautoaway/src/options.cpp b/src/core/stdautoaway/src/options.cpp index e8ee0669da..79f6795174 100644 --- a/src/core/stdautoaway/src/options.cpp +++ b/src/core/stdautoaway/src/options.cpp @@ -87,7 +87,7 @@ public: chkShortIdle.OnChange = chkShort.OnChange = Callback(this, &COptionsDlg::onChange); } - virtual void OnInitDialog() override + bool OnInitDialog() override { chkOnWindows.SetState(!g_plugin.bIdleMethod); @@ -99,9 +99,10 @@ public: cmbAAStatus.SetCurSel(IdleGetStatusIndex(g_plugin.bAAStatus)); ShowHide(); + return true; } - virtual void OnApply() override + bool OnApply() override { g_plugin.iIdleTime1st = spinIdle.GetPosition(); @@ -112,6 +113,7 @@ public: // destroy any current idle and reset settings. IdleObject_Destroy(); IdleObject_Create(); + return true; } void onChange(CCtrlCheck*) diff --git a/src/core/stdmsg/src/chat_options.cpp b/src/core/stdmsg/src/chat_options.cpp index 272b75ef6c..fc7258ce76 100644 --- a/src/core/stdmsg/src/chat_options.cpp +++ b/src/core/stdmsg/src/chat_options.cpp @@ -342,7 +342,7 @@ public: checkBoxes.OnItemChanged = Callback(this, &COptMainDlg::onChange_Tree); } - virtual void OnInitDialog() override + bool OnInitDialog() override { SetWindowLongPtr(checkBoxes.GetHwnd(), GWL_STYLE, GetWindowLongPtr(checkBoxes.GetHwnd(), GWL_STYLE) | TVS_NOHSCROLL | TVS_CHECKBOXES); @@ -363,9 +363,10 @@ public: FillBranch(hListHeading6, branch6, _countof(branch6), 0x0000); } FixHeadings(); + return true; } - virtual void OnApply() override + bool OnApply() override { SaveBranch(branch1, _countof(branch1)); SaveBranch(branch2, _countof(branch2)); @@ -377,9 +378,10 @@ public: g_chatApi.ReloadSettings(); Chat_UpdateOptions(); + return true; } - virtual void OnDestroy() override + void OnDestroy() override { BYTE b = checkBoxes.GetItemState(hListHeading1, TVIS_EXPANDED) & TVIS_EXPANDED ? 1 : 0; db_set_b(0, CHAT_MODULE, "Branch1Exp", b); @@ -464,7 +466,7 @@ public: btnFontChoose.OnClick = Callback(this, &COptLogDlg::onClick_Font); } - virtual void OnInitDialog() override + bool OnInitDialog() override { spin2.SetRange(5000); spin2.SetPosition(db_get_w(0, CHAT_MODULE, "LogLimit", 100)); @@ -493,9 +495,10 @@ public: chkLogging.SetState(g_Settings.bLoggingEnabled); onChange_Logging(nullptr); + return true; } - virtual void OnApply() override + bool OnApply() override { ptrW pszText(rtrimw(edtHighlight.GetText())); if (*pszText) { @@ -555,6 +558,7 @@ public: g_chatApi.ReloadSettings(); Chat_UpdateOptions(); + return true; } void onChange_Logging(CCtrlCheck*) @@ -610,7 +614,7 @@ public: chkRadio1.OnChange = chkRadio2.OnChange = chkRadio3.OnChange = Callback(this, &COptPopupDlg::onChange_Radio); } - virtual void OnInitDialog() override + bool OnInitDialog() override { SendDlgItemMessage(m_hwnd, IDC_BKG, CPM_SETCOLOUR, 0, g_Settings.crPUBkgColour); SendDlgItemMessage(m_hwnd, IDC_TEXT, CPM_SETCOLOUR, 0, g_Settings.crPUTextColour); @@ -627,9 +631,10 @@ public: SendDlgItemMessage(m_hwnd, IDC_SPIN1, UDM_SETRANGE, 0, MAKELONG(100, -1)); SendDlgItemMessage(m_hwnd, IDC_SPIN1, UDM_SETPOS, 0, MAKELONG(g_Settings.iPopupTimeout, 0)); + return true; } - virtual void OnApply() override + bool OnApply() override { int iLen; if (IsDlgButtonChecked(m_hwnd, IDC_RADIO2) == BST_CHECKED) @@ -649,6 +654,7 @@ public: db_set_dw(0, CHAT_MODULE, "PopupColorBG", (DWORD)SendDlgItemMessage(m_hwnd, IDC_BKG, CPM_GETCOLOUR, 0, 0)); g_Settings.crPUTextColour = SendDlgItemMessage(m_hwnd, IDC_TEXT, CPM_GETCOLOUR, 0, 0); db_set_dw(0, CHAT_MODULE, "PopupColorText", (DWORD)SendDlgItemMessage(m_hwnd, IDC_TEXT, CPM_GETCOLOUR, 0, 0)); + return true; } void onChange_Radio(CCtrlCheck*) diff --git a/src/core/stdmsg/src/chat_window.cpp b/src/core/stdmsg/src/chat_window.cpp index 459bb6575d..3f513be937 100644 --- a/src/core/stdmsg/src/chat_window.cpp +++ b/src/core/stdmsg/src/chat_window.cpp @@ -47,7 +47,7 @@ CChatRoomDlg::CChatRoomDlg(CTabbedWindow *pOwner, SESSION_INFO *si) : m_iSplitterY = g_Settings.iSplitterY; } -void CChatRoomDlg::OnInitDialog() +bool CChatRoomDlg::OnInitDialog() { CSuper::OnInitDialog(); m_si->pDlg = this; @@ -71,6 +71,7 @@ void CChatRoomDlg::OnInitDialog() UpdateTitle(); NotifyEvent(MSG_WINDOW_EVT_OPEN); + return true; } void CChatRoomDlg::OnDestroy() diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index 3b402181b5..cfb4c8d556 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -97,7 +97,7 @@ CSrmmWindow::CSrmmWindow(CTabbedWindow *pOwner, MCONTACT hContact) : m_splitter.OnChange = Callback(this, &CSrmmWindow::OnSplitterMoved); } -void CSrmmWindow::OnInitDialog() +bool CSrmmWindow::OnInitDialog() { CSuper::OnInitDialog(); @@ -251,6 +251,7 @@ void CSrmmWindow::OnInitDialog() SendMessage(m_hwnd, DM_GETAVATAR, 0, 0); NotifyEvent(MSG_WINDOW_EVT_OPEN); + return true; } void CSrmmWindow::OnDestroy() diff --git a/src/core/stdmsg/src/msgoptions.cpp b/src/core/stdmsg/src/msgoptions.cpp index f8d60c6be2..d8c88d0327 100644 --- a/src/core/stdmsg/src/msgoptions.cpp +++ b/src/core/stdmsg/src/msgoptions.cpp @@ -245,7 +245,7 @@ public: CreateLink(chkDoNotStealFocus, g_dat.bDoNotStealFocus); } - virtual void OnInitDialog() override + bool OnInitDialog() override { FillCheckBoxTree(g_dat.popupFlags); @@ -256,9 +256,10 @@ public: chkCascade.Enable(!g_dat.bSavePerContact); chkCtrlSupport.Enable(!g_dat.bAutoClose); + return true; } - virtual void OnApply() override + bool OnApply() override { g_dat.popupFlags = MakeCheckBoxTreeFlags(); @@ -268,6 +269,7 @@ public: g_dat.msgTimeout = msgTimeout; Srmm_Broadcast(DM_OPTIONSAPPLIED, TRUE, 0); + return true; } void onChange_AutoMin(CCtrlCheck*) @@ -342,7 +344,7 @@ public: CreateLink(chkShowNames, g_dat.bShowNames); } - virtual void OnInitDialog() override + bool OnInitDialog() override { switch (g_dat.iLoadHistory) { case LOADHISTORY_UNREAD: @@ -366,9 +368,10 @@ public: spinTime.SetPosition(g_dat.nLoadTime); onChange_Time(nullptr); + return true; } - virtual void OnApply() override + bool OnApply() override { if (chkLoadCount.GetState()) g_dat.iLoadHistory = LOADHISTORY_COUNT; @@ -382,9 +385,10 @@ public: FreeMsgLogIcons(); LoadMsgLogIcons(); Srmm_Broadcast(DM_OPTIONSAPPLIED, TRUE, 0); + return true; } - virtual void OnDestroy() override + void OnDestroy() override { DeleteObject(hBkgColourBrush); } @@ -474,7 +478,7 @@ public: } } - virtual void OnInitDialog() override + bool OnInitDialog() override { CLCINFOITEM cii = { sizeof(cii) }; cii.flags = CLCIIF_GROUPFONT | CLCIIF_CHECKBOX; @@ -491,12 +495,14 @@ public: clist.OnOptionsChanged = Callback(this, &COptionTypingDlg::ResetCList); onChange_ShowNotify(nullptr); + return true; } - virtual void OnApply() override + bool OnApply() override { SaveList(); Srmm_Broadcast(DM_OPTIONSAPPLIED, TRUE, 0); + return true; } void onChange_Clist(CCtrlClc::TEventInfo*) @@ -539,15 +545,16 @@ public: m_chkTabs.OnChange = Callback(this, &COptionsTabDlg::onChange_Tabs); } - virtual void OnInitDialog() override + bool OnInitDialog() override { m_chkTabs.SetState(g_Settings.bTabsEnable); m_chkTabsBottom.SetState(g_Settings.bTabsAtBottom); m_chkTabsClose.SetState(g_Settings.bTabCloseOnDblClick); onChange_Tabs(&m_chkTabs); + return true; } - virtual void OnApply() override + bool OnApply() override { BYTE bOldValue = db_get_b(0, CHAT_MODULE, "Tabs", 1); @@ -563,6 +570,7 @@ public: g_Settings.bTabsEnable = db_get_b(0, CHAT_MODULE, "Tabs", 1) != 0; } else Chat_UpdateOptions(); + return true; } void onChange_Tabs(CCtrlCheck *pCheck) diff --git a/src/core/stdmsg/src/msgs.h b/src/core/stdmsg/src/msgs.h index 2322ca2c99..6dfe7f31af 100644 --- a/src/core/stdmsg/src/msgs.h +++ b/src/core/stdmsg/src/msgs.h @@ -126,7 +126,7 @@ public: public: CSrmmWindow(CTabbedWindow*, MCONTACT hContact); - void OnInitDialog() override; + bool OnInitDialog() override; void OnDestroy() override; void OnActivate() override; @@ -183,7 +183,7 @@ class CChatRoomDlg : public CMsgDialog public: CChatRoomDlg(CTabbedWindow*, SESSION_INFO*); - void OnInitDialog() override; + bool OnInitDialog() override; void OnDestroy() override; void OnActivate() override; diff --git a/src/core/stdmsg/src/stdafx.h b/src/core/stdmsg/src/stdafx.h index 344b40992a..67c98ec5f5 100644 --- a/src/core/stdmsg/src/stdafx.h +++ b/src/core/stdmsg/src/stdafx.h @@ -173,11 +173,11 @@ public: void SetTabHighlight(CMsgDialog*); void TabClicked(); - virtual void OnInitDialog() override; - virtual void OnDestroy() override; + bool OnInitDialog() override; + void OnDestroy() override; - virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override; - virtual int Resizer(UTILRESIZECONTROL *urc) override; + INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override; + int Resizer(UTILRESIZECONTROL *urc) override; }; extern CTabbedWindow *g_pTabDialog; diff --git a/src/core/stdmsg/src/tabs.cpp b/src/core/stdmsg/src/tabs.cpp index 5a0537b45d..cf8c187512 100644 --- a/src/core/stdmsg/src/tabs.cpp +++ b/src/core/stdmsg/src/tabs.cpp @@ -144,7 +144,7 @@ CTabbedWindow::CTabbedWindow() : { } -void CTabbedWindow::OnInitDialog() +bool CTabbedWindow::OnInitDialog() { SetWindowLongPtr(m_tab.GetHwnd(), GWLP_USERDATA, LPARAM(this)); mir_subclassWindow(m_tab.GetHwnd(), ::TabSubclassProc); @@ -156,7 +156,7 @@ void CTabbedWindow::OnInitDialog() if (!g_Settings.bTabsEnable) { m_tab.Hide(); - return; + return false; } LONG_PTR mask = GetWindowLongPtr(m_tab.GetHwnd(), GWL_STYLE); @@ -168,6 +168,7 @@ void CTabbedWindow::OnInitDialog() TabCtrl_SetMinTabWidth(m_tab.GetHwnd(), 80); TabCtrl_SetImageList(m_tab.GetHwnd(), Clist_GetImageList()); + return true; } void CTabbedWindow::OnDestroy() diff --git a/src/mir_app/src/addcontact.cpp b/src/mir_app/src/addcontact.cpp index d16544fa8c..500aa2cae3 100644 --- a/src/mir_app/src/addcontact.cpp +++ b/src/mir_app/src/addcontact.cpp @@ -65,7 +65,7 @@ public: m_btnOk.OnClick = Callback(this, &CAddContactDlg::OnOk); } - void OnInitDialog() + bool OnInitDialog() override { Window_SetSkinIcon_IcoLib(m_hwnd, SKINICON_OTHER_ADDCONTACT); @@ -107,6 +107,7 @@ public: m_authReq.Enable(m_chkAuth.Enabled()); m_authReq.SetText(TranslateT("Please authorize my request and add me to your contact list.")); } + return true; } void OnDestroy() diff --git a/src/mir_app/src/auth.cpp b/src/mir_app/src/auth.cpp index 91200e360a..6633802df0 100644 --- a/src/mir_app/src/auth.cpp +++ b/src/mir_app/src/auth.cpp @@ -52,21 +52,21 @@ public: btnDetails.OnClick = Callback(this, &CAuthReqDlg::onClick_Details); } - virtual void OnInitDialog() override + bool OnInitDialog() override { Button_SetIcon_IcoLib(m_hwnd, IDC_DETAILS, SKINICON_OTHER_USERDETAILS, LPGEN("View user's details")); Button_SetIcon_IcoLib(m_hwnd, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add contact permanently to list")); int iBlobSize = db_event_getBlobSize(m_hDbEvent); if (iBlobSize == -1) - return; + return false; // blob is: uin(DWORD), hcontact(DWORD), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ) DBEVENTINFO dbei = {}; dbei.cbBlob = iBlobSize; dbei.pBlob = (PBYTE)alloca(dbei.cbBlob); if (db_event_get(m_hDbEvent, &dbei)) - return; + return false; m_szProto = dbei.szModule; @@ -131,9 +131,10 @@ public: chkAdd.SetState(false); } else chkAdd.SetState(true); + return true; } - virtual void OnDestroy() override + void OnDestroy() override { Button_FreeIcon_IcoLib(m_hwnd, IDC_ADD); Button_FreeIcon_IcoLib(m_hwnd, IDC_DETAILS); @@ -198,7 +199,7 @@ public: btnDetails.OnClick = Callback(this, &CAddedDlg::onClick_Details); } - virtual void OnInitDialog() override + bool OnInitDialog() override { Button_SetIcon_IcoLib(m_hwnd, IDC_DETAILS, SKINICON_OTHER_USERDETAILS, LPGEN("View user's details")); Button_SetIcon_IcoLib(m_hwnd, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add contact permanently to list")); @@ -255,9 +256,10 @@ public: if (m_hContact == INVALID_CONTACT_ID || !db_get_b(m_hContact, "CList", "NotOnList", 0)) ShowWindow(GetDlgItem(m_hwnd, IDC_ADD), FALSE); + return true; } - virtual void OnDestroy() override + void OnDestroy() override { Button_FreeIcon_IcoLib(m_hwnd, IDC_ADD); Button_FreeIcon_IcoLib(m_hwnd, IDC_DETAILS); diff --git a/src/mir_app/src/colorchooser.cpp b/src/mir_app/src/colorchooser.cpp index 95918e239d..8d9cb701c7 100644 --- a/src/mir_app/src/colorchooser.cpp +++ b/src/mir_app/src/colorchooser.cpp @@ -105,7 +105,7 @@ public: m_yPosition = IsWindowVisible(hwndChooser) ? rc.top - 1 : rc.top + 20; } - virtual void OnInitDialog() override + bool OnInitDialog() override { int iSquareRoot = (int)sqrt(static_cast(16)); @@ -127,9 +127,10 @@ public: m_text.SetText(m_bForeground ? TranslateT("Text color") : TranslateT("Background color")); SetWindowPos(m_text.GetHwnd(), nullptr, 0, 0, width, 20, 0); SetWindowPos(m_hwnd, nullptr, m_xPosition, m_yPosition, width, height, SWP_SHOWWINDOW); + return true; } - virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override + INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override { switch (msg) { case WM_COMMAND: @@ -265,9 +266,10 @@ public: return CDlgBase::DlgProc(msg, wParam, lParam); } - virtual void OnClose() override + bool OnClose() override { SetFocus(m_hwndTarget); + return true; } }; diff --git a/src/mir_app/src/contacts.cpp b/src/mir_app/src/contacts.cpp index 72a7e5d5b1..ba1df15b2e 100644 --- a/src/mir_app/src/contacts.cpp +++ b/src/mir_app/src/contacts.cpp @@ -314,7 +314,7 @@ public: m_nameOrder.OnBeginDrag = Callback(this, &CContactOptsDlg::OnBeginDrag); } - virtual void OnInitDialog() + bool OnInitDialog() override { TVINSERTSTRUCT tvis; tvis.hParent = nullptr; @@ -325,9 +325,10 @@ public: tvis.item.pszText = TranslateW(nameOrderDescr[nameOrder[i]]); m_nameOrder.InsertItem(&tvis); } + return true; } - virtual void OnApply() + bool OnApply() override { TVITEMEX tvi; tvi.hItem = m_nameOrder.GetRoot(); @@ -340,6 +341,7 @@ public: } db_set_blob(0, "Contact", "NameOrder", nameOrder, _countof(nameOrderDescr)); g_clistApi.pfnInvalidateDisplayNameCacheEntry(INVALID_CONTACT_ID); + return true; } void OnBeginDrag(CCtrlTreeView::TEventInfo *evt) diff --git a/src/mir_app/src/db_ini.cpp b/src/mir_app/src/db_ini.cpp index c35ac38817..a03aabc333 100644 --- a/src/mir_app/src/db_ini.cpp +++ b/src/mir_app/src/db_ini.cpp @@ -41,55 +41,51 @@ class CInstallIniDlg : public CDlgBase CCtrlBase m_securityInfo; protected: - void OnInitDialog(); + bool OnInitDialog() override + { + m_iniName.SetText(m_szIniPath); + + wchar_t szSecurity[11]; + const wchar_t *pszSecurityInfo; + + Profile_GetSetting(L"AutoExec/Warn", szSecurity, L"notsafe"); + if (!mir_wstrcmpi(szSecurity, L"all")) + pszSecurityInfo = LPGENW("Security systems to prevent malicious changes are in place and you will be warned before every change that is made."); + else if (!mir_wstrcmpi(szSecurity, L"onlyunsafe")) + pszSecurityInfo = LPGENW("Security systems to prevent malicious changes are in place and you will be warned before changes that are known to be unsafe."); + else if (!mir_wstrcmpi(szSecurity, L"none")) + pszSecurityInfo = LPGENW("Security systems to prevent malicious changes have been disabled. You will receive no further warnings."); + else pszSecurityInfo = nullptr; + + if (pszSecurityInfo) + m_securityInfo.SetText(TranslateW(pszSecurityInfo)); + return true; + } + + void ViewIni_OnClick(CCtrlBase*) + { + ptrW szPath(m_iniName.GetText()); + ShellExecute(m_hwnd, L"open", szPath, nullptr, nullptr, SW_SHOW); + } - void ViewIni_OnClick(CCtrlBase*); - void NoToAll_OnClick(CCtrlBase*); + void NoToAll_OnClick(CCtrlBase*) + { + Close(); + } public: - CInstallIniDlg(wchar_t *szIniPath); + CInstallIniDlg(wchar_t *szIniPath) : + CDlgBase(g_plugin, IDD_INSTALLINI), + m_noToAll(this, IDC_NOTOALL), m_viewIni(this, IDC_VIEWINI), + m_iniName(this, IDC_ININAME), m_securityInfo(this, IDC_SECURITYINFO) + { + m_szIniPath = szIniPath; + + m_noToAll.OnClick = Callback(this, &CInstallIniDlg::NoToAll_OnClick); + m_viewIni.OnClick = Callback(this, &CInstallIniDlg::ViewIni_OnClick); + } }; -CInstallIniDlg::CInstallIniDlg(wchar_t *szIniPath) - : CDlgBase(g_plugin, IDD_INSTALLINI), - m_noToAll(this, IDC_NOTOALL), m_viewIni(this, IDC_VIEWINI), - m_iniName(this, IDC_ININAME), m_securityInfo(this, IDC_SECURITYINFO) -{ - m_szIniPath = szIniPath; - - m_noToAll.OnClick = Callback(this, &CInstallIniDlg::NoToAll_OnClick); - m_viewIni.OnClick = Callback(this, &CInstallIniDlg::ViewIni_OnClick); -} - -void CInstallIniDlg::OnInitDialog() -{ - m_iniName.SetText(m_szIniPath); - - wchar_t szSecurity[11]; - const wchar_t *pszSecurityInfo; - - Profile_GetSetting(L"AutoExec/Warn", szSecurity, L"notsafe"); - if (!mir_wstrcmpi(szSecurity, L"all")) - pszSecurityInfo = LPGENW("Security systems to prevent malicious changes are in place and you will be warned before every change that is made."); - else if (!mir_wstrcmpi(szSecurity, L"onlyunsafe")) - pszSecurityInfo = LPGENW("Security systems to prevent malicious changes are in place and you will be warned before changes that are known to be unsafe."); - else if (!mir_wstrcmpi(szSecurity, L"none")) - pszSecurityInfo = LPGENW("Security systems to prevent malicious changes have been disabled. You will receive no further warnings."); - else pszSecurityInfo = nullptr; - if (pszSecurityInfo) m_securityInfo.SetText(TranslateW(pszSecurityInfo)); -} - -void CInstallIniDlg::ViewIni_OnClick(CCtrlBase*) -{ - ptrW szPath(m_iniName.GetText()); - ShellExecute(m_hwnd, L"open", szPath, nullptr, nullptr, SW_SHOW); -} - -void CInstallIniDlg::NoToAll_OnClick(CCtrlBase*) -{ - Close(); -} - ////////////////////////////////////////////////////// static bool IsInSpaceSeparatedList(const char *szWord, const char *szList) @@ -137,60 +133,54 @@ class CWarnIniChangeDlg : public CDlgBase CCtrlBase m_newValue; protected: - void OnInitDialog(); + bool OnInitDialog() override + { + char szSettingName[256]; + const wchar_t *pszSecurityInfo; + m_iniName.SetText(m_warnInfo->szIniPath); + mir_strcpy(szSettingName, m_warnInfo->szSection); + mir_strcat(szSettingName, " / "); + mir_strcat(szSettingName, m_warnInfo->szName); + m_settingName.SetTextA(szSettingName); + m_newValue.SetTextA(m_warnInfo->szValue); + if (IsInSpaceSeparatedList(m_warnInfo->szSection, m_warnInfo->szSafeSections)) + pszSecurityInfo = LPGENW("This change is known to be safe."); + else if (IsInSpaceSeparatedList(m_warnInfo->szSection, m_warnInfo->szUnsafeSections)) + pszSecurityInfo = LPGENW("This change is known to be potentially hazardous."); + else + pszSecurityInfo = LPGENW("This change is not known to be safe."); + m_securityInfo.SetText(TranslateW(pszSecurityInfo)); + return true; + } + + void YesNo_OnClick(CCtrlBase*) + { + m_warnInfo->warnNoMore = m_noWarn.GetState(); + Close(); + } - void YesNo_OnClick(CCtrlBase*); - void Cancel_OnClick(CCtrlBase*); + void Cancel_OnClick(CCtrlBase*) + { + m_warnInfo->cancel = 1; + m_warnInfo->warnNoMore = m_noWarn.GetState(); + } public: - CWarnIniChangeDlg(warnSettingChangeInfo_t *warnInfo); + CWarnIniChangeDlg(warnSettingChangeInfo_t *warnInfo) : + CDlgBase(g_plugin, IDD_WARNINICHANGE), + m_yes(this, IDYES), m_no(this, IDNO), + m_cancel(this, IDCANCEL), m_noWarn(this, IDC_WARNNOMORE), + m_iniName(this, IDC_ININAME), m_settingName(this, IDC_SETTINGNAME), + m_newValue(this, IDC_NEWVALUE), m_securityInfo(this, IDC_SECURITYINFO) + { + m_warnInfo = warnInfo; + + m_yes.OnClick = Callback(this, &CWarnIniChangeDlg::YesNo_OnClick); + m_no.OnClick = Callback(this, &CWarnIniChangeDlg::YesNo_OnClick); + m_cancel.OnClick = Callback(this, &CWarnIniChangeDlg::Cancel_OnClick); + } }; -CWarnIniChangeDlg::CWarnIniChangeDlg(warnSettingChangeInfo_t *warnInfo) - : CDlgBase(g_plugin, IDD_WARNINICHANGE), - m_yes(this, IDYES), m_no(this, IDNO), - m_cancel(this, IDCANCEL), m_noWarn(this, IDC_WARNNOMORE), - m_iniName(this, IDC_ININAME), m_settingName(this, IDC_SETTINGNAME), - m_newValue(this, IDC_NEWVALUE), m_securityInfo(this, IDC_SECURITYINFO) -{ - m_warnInfo = warnInfo; - - m_yes.OnClick = Callback(this, &CWarnIniChangeDlg::YesNo_OnClick); - m_no.OnClick = Callback(this, &CWarnIniChangeDlg::YesNo_OnClick); - m_cancel.OnClick = Callback(this, &CWarnIniChangeDlg::Cancel_OnClick); -} - -void CWarnIniChangeDlg::OnInitDialog() -{ - char szSettingName[256]; - const wchar_t *pszSecurityInfo; - m_iniName.SetText(m_warnInfo->szIniPath); - mir_strcpy(szSettingName, m_warnInfo->szSection); - mir_strcat(szSettingName, " / "); - mir_strcat(szSettingName, m_warnInfo->szName); - m_settingName.SetTextA(szSettingName); - m_newValue.SetTextA(m_warnInfo->szValue); - if (IsInSpaceSeparatedList(m_warnInfo->szSection, m_warnInfo->szSafeSections)) - pszSecurityInfo = LPGENW("This change is known to be safe."); - else if (IsInSpaceSeparatedList(m_warnInfo->szSection, m_warnInfo->szUnsafeSections)) - pszSecurityInfo = LPGENW("This change is known to be potentially hazardous."); - else - pszSecurityInfo = LPGENW("This change is not known to be safe."); - m_securityInfo.SetText(TranslateW(pszSecurityInfo)); -} - -void CWarnIniChangeDlg::YesNo_OnClick(CCtrlBase*) -{ - m_warnInfo->warnNoMore = m_noWarn.GetState(); - Close(); -} - -void CWarnIniChangeDlg::Cancel_OnClick(CCtrlBase*) -{ - m_warnInfo->cancel = 1; - m_warnInfo->warnNoMore = m_noWarn.GetState(); -} - ////////////////////////////////////////////////////// class CIniImportDoneDlg : public CDlgBase @@ -206,62 +196,55 @@ class CIniImportDoneDlg : public CDlgBase CCtrlEdit m_newPath; protected: - void OnInitDialog(); - - void Delete_OnClick(CCtrlBase*); - void Leave_OnClick(CCtrlBase*); - void Recycle_OnClick(CCtrlBase*); - void Move_OnClick(CCtrlBase*); - -public: - CIniImportDoneDlg(wchar_t *path); -}; + bool OnInitDialog() override + { + m_iniPath.SetText(m_path); + m_newPath.SetText(m_path); + return true; + } -void CIniImportDoneDlg::OnInitDialog() -{ - m_iniPath.SetText(m_path); - m_newPath.SetText(m_path); -} + void Delete_OnClick(CCtrlBase*) + { + ptrW szIniPath(m_iniPath.GetText()); + DeleteFile(szIniPath); + Close(); + } -CIniImportDoneDlg::CIniImportDoneDlg(wchar_t *path) - : CDlgBase(g_plugin, IDD_INIIMPORTDONE), - m_delete(this, IDC_DELETE), m_leave(this, IDC_LEAVE), - m_recycle(this, IDC_RECYCLE), m_move(this, IDC_MOVE), - m_iniPath(this, IDC_ININAME), m_newPath(this, IDC_NEWNAME) -{ - m_path = path; -} -void CIniImportDoneDlg::Delete_OnClick(CCtrlBase*) -{ - ptrW szIniPath(m_iniPath.GetText()); - DeleteFile(szIniPath); - Close(); -} + void Leave_OnClick(CCtrlBase*) + { + Close(); + } -void CIniImportDoneDlg::Recycle_OnClick(CCtrlBase*) -{ - ptrW szIniPath(m_iniPath.GetText()); - SHFILEOPSTRUCT shfo = {}; - shfo.wFunc = FO_DELETE; - shfo.pFrom = szIniPath; - szIniPath[mir_wstrlen(szIniPath) + 1] = '\0'; - shfo.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT | FOF_ALLOWUNDO; - SHFileOperation(&shfo); - Close(); -} + void Recycle_OnClick(CCtrlBase*) + { + ptrW szIniPath(m_iniPath.GetText()); + SHFILEOPSTRUCT shfo = {}; + shfo.wFunc = FO_DELETE; + shfo.pFrom = szIniPath; + szIniPath[mir_wstrlen(szIniPath) + 1] = '\0'; + shfo.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT | FOF_ALLOWUNDO; + SHFileOperation(&shfo); + Close(); + } -void CIniImportDoneDlg::Move_OnClick(CCtrlBase*) -{ - ptrW szIniPath(m_iniPath.GetText()); - ptrW szNewPath(m_newPath.GetText()); - MoveFile(szIniPath, szNewPath); - Close(); -} + void Move_OnClick(CCtrlBase*) + { + ptrW szIniPath(m_iniPath.GetText()); + ptrW szNewPath(m_newPath.GetText()); + MoveFile(szIniPath, szNewPath); + Close(); + } -void CIniImportDoneDlg::Leave_OnClick(CCtrlBase*) -{ - Close(); -} +public: + CIniImportDoneDlg(wchar_t *path) : + CDlgBase(g_plugin, IDD_INIIMPORTDONE), + m_delete(this, IDC_DELETE), m_leave(this, IDC_LEAVE), + m_recycle(this, IDC_RECYCLE), m_move(this, IDC_MOVE), + m_iniPath(this, IDC_ININAME), m_newPath(this, IDC_NEWNAME) + { + m_path = path; + } +}; ////////////////////////////////////////////////////// diff --git a/src/mir_app/src/ei_options.cpp b/src/mir_app/src/ei_options.cpp index 50cdcc1ce3..7f763d87c8 100644 --- a/src/mir_app/src/ei_options.cpp +++ b/src/mir_app/src/ei_options.cpp @@ -254,7 +254,7 @@ public: m_timer.OnEvent = Callback(this, &CExtraIconOptsDlg::onTimer); } - virtual void OnInitDialog() + bool OnInitDialog() override { pGlgOptions = this; @@ -266,9 +266,10 @@ public: } BuildIconList(); + return true; } - virtual void OnApply() + bool OnApply() override { // Store old slots int *oldSlots = new int[registeredExtraIcons.getCount()]; @@ -367,9 +368,10 @@ public: extra->applyIcons(); delete[] oldSlots; + return true; } - virtual void OnDestroy() + void OnDestroy() override { pGlgOptions = nullptr; diff --git a/src/mir_app/src/help.cpp b/src/mir_app/src/help.cpp index 1b0aa39d5a..8eef92a7cf 100644 --- a/src/mir_app/src/help.cpp +++ b/src/mir_app/src/help.cpp @@ -50,7 +50,7 @@ public: ctrlDevelopers.UseSystemColors(); } - virtual void OnInitDialog() override + bool OnInitDialog() override { ptrW wszCopyright(mir_utf8decodeW(LEGAL_COPYRIGHT)); if (wszCopyright == nullptr) @@ -82,9 +82,10 @@ public: ctrlCredits.Hide(); Window_SetSkinIcon_IcoLib(m_hwnd, SKINICON_OTHER_MIRANDA); + return true; } - virtual void OnDestroy() override + void OnDestroy() override { pAboutDialog = nullptr; Window_FreeIcon_IcoLib(m_hwnd); diff --git a/src/mir_app/src/lpopts.cpp b/src/mir_app/src/lpopts.cpp index 01916a1a16..b3fd2d488a 100644 --- a/src/mir_app/src/lpopts.cpp +++ b/src/mir_app/src/lpopts.cpp @@ -57,9 +57,9 @@ class CLangpackDlg : public CDlgBase void DisplayPackInfo(const LANGPACK_INFO *pack); protected: - void OnInitDialog(); - void OnApply(); - void OnDestroy(); + bool OnInitDialog() override; + bool OnApply() override; + void OnDestroy() override; void Languages_OnChange(CCtrlBase*); void Reload_OnClick(CCtrlBase*); @@ -80,10 +80,11 @@ CLangpackDlg::CLangpackDlg() m_reload.OnClick = Callback(this, &CLangpackDlg::Reload_OnClick); } -void CLangpackDlg::OnInitDialog() +bool CLangpackDlg::OnInitDialog() { m_languages.ResetContent(); LoadLangpacks(); + return true; } void CLangpackDlg::LoadLangpacks() @@ -217,7 +218,7 @@ void CLangpackDlg::Reload_OnClick(CCtrlBase*) m_reload.Enable(TRUE); } -void CLangpackDlg::OnApply() +bool CLangpackDlg::OnApply() { wchar_t tszPath[MAX_PATH]; tszPath[0] = 0; int idx = m_languages.GetCurSel(); @@ -241,6 +242,7 @@ void CLangpackDlg::OnApply() mir_forkthread(ReloadOptions, hwndParent); } } + return true; } void CLangpackDlg::OnDestroy() diff --git a/src/mir_app/src/menu_options.cpp b/src/mir_app/src/menu_options.cpp index 333426c5d7..011dff0698 100644 --- a/src/mir_app/src/menu_options.cpp +++ b/src/mir_app/src/menu_options.cpp @@ -321,7 +321,7 @@ public: } //---- init dialog ------------------------------------------- - virtual void OnInitDialog() + bool OnInitDialog() override { iInitMenuValue = db_get_b(0, "CList", "MoveProtoMenus", TRUE); @@ -339,9 +339,10 @@ public: m_menuObjects.SetCurSel(0); RebuildCurrent(); + return true; } - virtual void OnApply() + bool OnApply() override { bIconsDisabled = m_enableIcons.GetState() == 0; db_set_b(0, "CList", "DisableMenuIcons", bIconsDisabled); @@ -355,9 +356,10 @@ public: iInitMenuValue = iNewMenuValue; } RebuildCurrent(); + return true; } - virtual void OnDestroy() + void OnDestroy() override { FreeTreeData(); } diff --git a/src/mir_app/src/meta_addto.cpp b/src/mir_app/src/meta_addto.cpp index d2d8e38dcc..9687fc5c33 100644 --- a/src/mir_app/src/meta_addto.cpp +++ b/src/mir_app/src/meta_addto.cpp @@ -94,8 +94,8 @@ static int BuildList(HWND list, BOOL sort) * * @param hwndDlg : HANDLE to the 'Add To' Dialog. * @param uMsg : Specifies the message received by this dialog. -* @param wParam : Specifies additional message-specific information. -* @param lParam : Specifies additional message-specific information. +* @param wParam : Specifies additional message-specific information. +* @param lParam : Specifies additional message-specific information. * * @return TRUE if the dialog processed the message, FALSE if it did not. */ @@ -112,9 +112,9 @@ class CMetaSelectDlg : public CDlgBase CCtrlCheck m_sortCheck; protected: - void OnInitDialog(); - void OnApply(); - void OnDestroy(); + bool OnInitDialog() override; + bool OnApply() override; + void OnDestroy() override; void MetaList_OnDblClick(CCtrlListBox*); void SortCheck_OnChange(CCtrlCheck*); @@ -131,31 +131,24 @@ CMetaSelectDlg::CMetaSelectDlg(MCONTACT hContact) m_sortCheck.OnChange = Callback(this, &CMetaSelectDlg::SortCheck_OnChange); } -void CMetaSelectDlg::OnInitDialog() +bool CMetaSelectDlg::OnInitDialog() { DBCachedContact *cc = currDb->getCache()->GetCachedContact(m_hContact); if (cc == nullptr) - { - Close(); - return; - } + return false; - if (cc->IsMeta()) - { + if (cc->IsMeta()) { MessageBox(GetHwnd(), TranslateT("This contact is a metacontact.\nYou can't add a metacontact to another metacontact.\n\nPlease choose another."), TranslateT("Metacontact conflict"), MB_ICONERROR); - Close(); - return; + return false; } - if (cc->IsSub()) - { + if (cc->IsSub()) { MessageBox(GetHwnd(), TranslateT("This contact is already associated to a metacontact.\nYou cannot add a contact to multiple metacontacts."), TranslateT("Multiple metacontacts"), MB_ICONERROR); - Close(); - return; + return false; } Window_SetIcon_IcoLib(GetHwnd(), Meta_GetIconHandle(I_ADD)); @@ -163,33 +156,29 @@ void CMetaSelectDlg::OnInitDialog() // Initialize the graphical part CheckDlgButton(GetHwnd(), IDC_ONLYAVAIL, BST_CHECKED); // Initially checked; display all metacontacts is only an option // Besides, we can check if there is at least one metacontact to add the contact to. - if (BuildList(GetDlgItem(GetHwnd(), IDC_METALIST), FALSE) <= 0) - { + if (BuildList(GetDlgItem(GetHwnd(), IDC_METALIST), FALSE) <= 0) { if (MessageBox(GetHwnd(), TranslateW(szConvMsg), TranslateT("No suitable metacontact found"), MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON1) == IDYES) Meta_Convert(m_hContact, 0); - Close(); - return; - } - else - { - // get contact display name from clist - wchar_t *ptszCDN = Clist_GetContactDisplayName(m_hContact); - if (!ptszCDN) - ptszCDN = TranslateT("a contact"); - - // ... and set it to the Window title. - wchar_t buf[256]; - mir_snwprintf(buf, TranslateT("Adding %s..."), ptszCDN); - SetWindowText(GetHwnd(), buf); + return false; } + + // get contact display name from clist + wchar_t *ptszCDN = Clist_GetContactDisplayName(m_hContact); + if (!ptszCDN) + ptszCDN = TranslateT("a contact"); + + // ... and set it to the Window title. + wchar_t buf[256]; + mir_snwprintf(buf, TranslateT("Adding %s..."), ptszCDN); + SetWindowText(GetHwnd(), buf); ShowWindow(GetHwnd(), SW_SHOWNORMAL); + return true; } -void CMetaSelectDlg::OnApply() +bool CMetaSelectDlg::OnApply() { int item = m_metaList.GetCurSel(); - if (item == -1) - { + if (item == -1) { BOOL result = IDOK == MessageBox(GetHwnd(), TranslateT("Please select a metacontact"), TranslateT("No metacontact selected"), MB_ICONHAND); EndModal(result); } @@ -197,6 +186,7 @@ void CMetaSelectDlg::OnApply() MCONTACT hMeta = (MCONTACT)m_metaList.GetItemData(item); if (!Meta_Assign(m_hContact, hMeta, FALSE)) MessageBox(GetHwnd(), TranslateT("Assignment to the metacontact failed."), TranslateT("Assignment failure"), MB_ICONERROR); + return true; } void CMetaSelectDlg::OnDestroy() @@ -216,8 +206,7 @@ void CMetaSelectDlg::MetaList_OnDblClick(CCtrlListBox*) void CMetaSelectDlg::SortCheck_OnChange(CCtrlCheck*) { SetWindowLongPtr(m_metaList.GetHwnd(), GWL_STYLE, GetWindowLongPtr(m_metaList.GetHwnd(), GWL_STYLE) ^ LBS_SORT); - if (BuildList(m_metaList.GetHwnd(), m_sortCheck.GetState() ? TRUE : FALSE) <= 0) - { + if (BuildList(m_metaList.GetHwnd(), m_sortCheck.GetState() ? TRUE : FALSE) <= 0) { if (MessageBox(GetHwnd(), TranslateW(szConvMsg), TranslateT("No suitable metacontact found"), MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON1) == IDYES) Meta_Convert(m_hContact, 0); Close(); diff --git a/src/mir_app/src/meta_options.cpp b/src/mir_app/src/meta_options.cpp index f80d9c3019..798af79448 100644 --- a/src/mir_app/src/meta_options.cpp +++ b/src/mir_app/src/meta_options.cpp @@ -70,7 +70,7 @@ public: { } - virtual void OnInitDialog() + bool OnInitDialog() override { m_btnLock.SetState(g_metaOptions.bLockHandle); m_btnCheck.SetState(g_metaOptions.bSuppressStatus); @@ -90,9 +90,10 @@ public: m_btnNick.SetState(true); else m_btnName.SetState(true); + return true; } - virtual void OnApply() + bool OnApply() override { g_metaOptions.bLockHandle = m_btnLock.GetState() != 0; g_metaOptions.bSuppressStatus = m_btnCheck.GetState() != 0; @@ -111,6 +112,7 @@ public: Meta_SuppressStatus(g_metaOptions.bSuppressStatus); Meta_SetAllNicks(); + return true; } }; diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 3b8a50f6eb..52a7b20b21 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -400,7 +400,7 @@ Chat_UpdateOptions @418 NONAME ?UpdateOptions@CSrmmBaseDialog@@UAEXXZ @420 NONAME ?ShowColorChooser@CSrmmBaseDialog@@QAEXH@Z @421 NONAME ?ShowFilterMenu@CSrmmBaseDialog@@UAEXXZ @422 NONAME -?OnInitDialog@CSrmmBaseDialog@@MAEXXZ @423 NONAME +?OnInitDialog@CSrmmBaseDialog@@MAE_NXZ @423 NONAME ?StreamInEvents@CSrmmBaseDialog@@UAEXPAULOGINFO@@_N@Z @424 NONAME ?AddLog@CSrmmBaseDialog@@UAEXXZ @425 NONAME ?RedrawLog2@CSrmmBaseDialog@@QAEXXZ @426 NONAME diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 5678c9d5e2..360fe8adea 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -400,7 +400,7 @@ Chat_UpdateOptions @418 NONAME ?UpdateOptions@CSrmmBaseDialog@@UEAAXXZ @420 NONAME ?ShowColorChooser@CSrmmBaseDialog@@QEAAXH@Z @421 NONAME ?ShowFilterMenu@CSrmmBaseDialog@@UEAAXXZ @422 NONAME -?OnInitDialog@CSrmmBaseDialog@@MEAAXXZ @423 NONAME +?OnInitDialog@CSrmmBaseDialog@@MEAA_NXZ @423 NONAME ?StreamInEvents@CSrmmBaseDialog@@UEAAXPEAULOGINFO@@_N@Z @424 NONAME ?AddLog@CSrmmBaseDialog@@UEAAXXZ @425 NONAME ?RedrawLog2@CSrmmBaseDialog@@QEAAXXZ @426 NONAME diff --git a/src/mir_app/src/miranda.cpp b/src/mir_app/src/miranda.cpp index 60e9553540..29ca6bba52 100644 --- a/src/mir_app/src/miranda.cpp +++ b/src/mir_app/src/miranda.cpp @@ -200,48 +200,41 @@ class CWaitRestartDlg : public CDlgBase CCtrlButton m_cancel; protected: - void OnInitDialog(); - - void Timer_OnEvent(CTimer*); - - void Cancel_OnClick(CCtrlBase*); - -public: - CWaitRestartDlg(HANDLE hProcess); -}; - -CWaitRestartDlg::CWaitRestartDlg(HANDLE hProcess) - : CDlgBase(g_plugin, IDD_WAITRESTART), m_timer(this, 1), - m_progress(this, IDC_PROGRESSBAR), m_cancel(this, IDCANCEL) -{ - m_autoClose = 0; - m_hProcess = hProcess; - m_timer.OnEvent = Callback(this, &CWaitRestartDlg::Timer_OnEvent); - m_cancel.OnClick = Callback(this, &CWaitRestartDlg::Cancel_OnClick); -} + bool OnInitDialog() override + { + m_progress.SetRange(MIRANDA_PROCESS_WAIT_STEPS); + m_progress.SetStep(1); + m_timer.Start(MIRANDA_PROCESS_WAIT_RESOLUTION); + return true; + } -void CWaitRestartDlg::OnInitDialog() -{ - m_progress.SetRange(MIRANDA_PROCESS_WAIT_STEPS); - m_progress.SetStep(1); - m_timer.Start(MIRANDA_PROCESS_WAIT_RESOLUTION); -} + void Timer_OnEvent(CTimer*) + { + if (m_progress.Move() == MIRANDA_PROCESS_WAIT_STEPS) + EndModal(0); + if (WaitForSingleObject(m_hProcess, 1) != WAIT_TIMEOUT) { + m_progress.SetPosition(MIRANDA_PROCESS_WAIT_STEPS); + EndModal(0); + } + } -void CWaitRestartDlg::Timer_OnEvent(CTimer*) -{ - if (m_progress.Move() == MIRANDA_PROCESS_WAIT_STEPS) - EndModal(0); - if (WaitForSingleObject(m_hProcess, 1) != WAIT_TIMEOUT) { + void Cancel_OnClick(CCtrlBase*) + { m_progress.SetPosition(MIRANDA_PROCESS_WAIT_STEPS); - EndModal(0); + EndModal(1); } -} -void CWaitRestartDlg::Cancel_OnClick(CCtrlBase*) -{ - m_progress.SetPosition(MIRANDA_PROCESS_WAIT_STEPS); - EndModal(1); -} +public: + CWaitRestartDlg(HANDLE hProcess) + : CDlgBase(g_plugin, IDD_WAITRESTART), m_timer(this, 1), + m_progress(this, IDC_PROGRESSBAR), m_cancel(this, IDCANCEL) + { + m_autoClose = 0; + m_hProcess = hProcess; + m_timer.OnEvent = Callback(this, &CWaitRestartDlg::Timer_OnEvent); + m_cancel.OnClick = Callback(this, &CWaitRestartDlg::Cancel_OnClick); + } +}; INT_PTR CheckRestart() { diff --git a/src/mir_app/src/options.cpp b/src/mir_app/src/options.cpp index cb1492ec27..ddd93d997f 100644 --- a/src/mir_app/src/options.cpp +++ b/src/mir_app/src/options.cpp @@ -179,7 +179,7 @@ public: { } - virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) + INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override { if (msg == WM_INITDIALOG) lParam = m_lParam; @@ -714,7 +714,7 @@ public: m_timerRebuild.OnEvent = Callback(this, &COptionsDlg::onNewPageTimer); } - virtual void OnInitDialog() override + bool OnInitDialog() override { Utils_RestoreWindowPositionNoSize(m_hwnd, 0, "Options", ""); Window_SetSkinIcon_IcoLib(m_hwnd, SKINICON_OTHER_OPTIONS); @@ -787,9 +787,10 @@ public: FillFilterCombo(); RebuildPageTree(); + return true; } - virtual void OnDestroy() override + void OnDestroy() override { ClearFilterStrings(); m_szFilterString[0] = 0; @@ -824,7 +825,7 @@ public: pOptionsDlg = nullptr; } - virtual void OnApply() override + bool OnApply() override { m_btnApply.Disable(); SetFocus(m_pageTree.GetHwnd()); @@ -836,7 +837,7 @@ public: pshn.hdr.code = PSN_KILLACTIVE; pshn.hdr.hwndFrom = opd->getHwnd(); if (SendMessage(opd->getHwnd(), WM_NOTIFY, 0, (LPARAM)&pshn)) - return; + return false; } LIST arChanged(10, CompareOPD); @@ -863,7 +864,7 @@ public: if (opd) opd->pDialog->Show(); m_bInsideApply = false; - return; + return false; } } m_bInsideApply = false; @@ -886,6 +887,7 @@ public: SendMessage(p->pDialog->GetHwnd(), WM_NOTIFY, 0, (LPARAM)&pshn); } + return true; } void btnApply_Click(CCtrlButton*) @@ -1038,7 +1040,7 @@ public: SetFocus(m_pageTree.GetHwnd()); } - virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override + INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override { switch (msg) { case PSM_CHANGED: diff --git a/src/mir_app/src/pluginopts.cpp b/src/mir_app/src/pluginopts.cpp index 3d2f8a929c..48e29fd535 100644 --- a/src/mir_app/src/pluginopts.cpp +++ b/src/mir_app/src/pluginopts.cpp @@ -272,7 +272,7 @@ public: m_plugList.OnKeyDown = Callback(this, &CPluginOptDlg::list_OnKeyDown); } - virtual void OnInitDialog() override + bool OnInitDialog() override { HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 4, 0); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_UNICODE); @@ -322,9 +322,10 @@ public: m_plugList.SetColumnWidth(2, max); m_plugList.SortItems(SortPlugins, (LPARAM)m_hwnd); + return true; } - virtual void OnApply() override + bool OnApply() override { CMStringW bufRestart(TranslateT("Miranda NG must be restarted to apply changes for these plugins:")); bufRestart.AppendChar('\n'); @@ -385,9 +386,10 @@ public: if (MessageBox(m_hwnd, bufRestart, L"Miranda NG", MB_ICONWARNING | MB_YESNO) == IDYES) CallService(MS_SYSTEM_RESTART, 1, 0); } + return true; } - virtual void OnDestroy() override + void OnDestroy() override { arPluginList.destroy(); diff --git a/src/mir_app/src/profilemanager.cpp b/src/mir_app/src/profilemanager.cpp index ad50cbbde8..9bdc5bb863 100644 --- a/src/mir_app/src/profilemanager.cpp +++ b/src/mir_app/src/profilemanager.cpp @@ -139,7 +139,7 @@ public: m_warning(this, IDC_NODBDRIVERS) {} - virtual void OnInitDialog() + bool OnInitDialog() override { // what, no plugins?! if (arDbPlugins.getCount() == 0) { @@ -175,9 +175,10 @@ public: // focus on the textbox PostMessage(m_hwnd, WM_FOCUSTEXTBOX, 0, 0); + return true; } - virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) + INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override { switch (msg) { case WM_FOCUSTEXTBOX: @@ -201,15 +202,15 @@ public: return CDlgBase::DlgProc(msg, wParam, lParam); } - virtual void OnApply() + bool OnApply() override { LRESULT curSel = m_driverList.GetCurSel(); if (curSel == -1 || !m_bFocused) - return; // should never happen + return false; // should never happen ptrW szName(m_profileName.GetText()); if (mir_wstrlen(szName) == 0) - return; + return false; // profile placed in "profile_name" subfolder mir_snwprintf(m_pd->ptszProfile, MAX_PATH, L"%s\\%s\\%s.dat", m_pd->ptszProfileDir, szName, szName); @@ -220,6 +221,7 @@ public: SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE); else m_pd->bRun = true; + return true; } }; @@ -443,7 +445,7 @@ public: m_profileList.OnDoubleClick = Callback(this, &CChooseProfileDlg::list_OnDblClick); } - virtual void OnInitDialog() + bool OnInitDialog() override { // set columns LVCOLUMN col; @@ -479,9 +481,10 @@ public: m_hFileNotify = FindFirstChangeNotification(m_pd->ptszProfileDir, TRUE, FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_LAST_WRITE); if (m_hFileNotify != INVALID_HANDLE_VALUE) SetTimer(m_hwnd, 0, 1200, nullptr); + return true; } - virtual void OnDestroy() + void OnDestroy() { KillTimer(m_hwnd, 0); FindCloseChangeNotification(m_hFileNotify); @@ -524,7 +527,7 @@ public: EndDialog(GetParent(m_hwndParent), 1); } - virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) + INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override { switch (msg) { case WM_TIMER: @@ -583,7 +586,7 @@ public: m_tab.AddPage(LPGENW("New profile"), nullptr, new CCreateProfileDlg(m_btnOk, m_pd)); } - virtual void OnInitDialog() + bool OnInitDialog() override { // MUST NOT be replaced with Window_SetIcon_IcoLib!!! SendMessage(m_hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_DETAILSLOGO), IMAGE_ICON, g_iIconSX, g_iIconSY, 0)); @@ -606,9 +609,10 @@ public: m_servicePlugs.AddString(TranslateW(p->pluginname), i); } } + return true; } - virtual void OnDestroy() + void OnDestroy() { LRESULT curSel = m_servicePlugs.GetCurSel(); if (curSel != -1) { diff --git a/src/mir_app/src/proto_internal.cpp b/src/mir_app/src/proto_internal.cpp index 4454e80439..616d84402d 100644 --- a/src/mir_app/src/proto_internal.cpp +++ b/src/mir_app/src/proto_internal.cpp @@ -52,22 +52,22 @@ struct DEFAULT_PROTO_INTERFACE : public PROTO_INTERFACE PROTO_INTERFACE(pszModuleName, ptszUserName) {} - virtual MCONTACT AddToList(int flags, PROTOSEARCHRESULT *psr) override + MCONTACT AddToList(int flags, PROTOSEARCHRESULT *psr) override { return (MCONTACT)ProtoCallService(m_szModuleName, PS_ADDTOLIST, flags, (LPARAM)psr); } - virtual MCONTACT AddToListByEvent(int flags, int iContact, MEVENT hDbEvent) override + MCONTACT AddToListByEvent(int flags, int iContact, MEVENT hDbEvent) override { return (MCONTACT)ProtoCallService(m_szModuleName, PS_ADDTOLISTBYEVENT, MAKELONG(flags, iContact), hDbEvent); } - virtual int Authorize(MEVENT hDbEvent) override + int Authorize(MEVENT hDbEvent) override { return (int)ProtoCallService(m_szModuleName, PS_AUTHALLOW, (WPARAM)hDbEvent, 0); } - virtual int AuthDeny(MEVENT hDbEvent, const wchar_t *szReason) override + int AuthDeny(MEVENT hDbEvent, const wchar_t *szReason) override { if (m_iVersion > 1) return (int)ProtoCallService(m_szModuleName, PS_AUTHDENY, hDbEvent, (LPARAM)szReason); @@ -75,13 +75,13 @@ struct DEFAULT_PROTO_INTERFACE : public PROTO_INTERFACE return (int)ProtoCallService(m_szModuleName, PS_AUTHDENY, hDbEvent, _T2A(szReason)); } - virtual int AuthRecv(MCONTACT hContact, PROTORECVEVENT *evt) override + int AuthRecv(MCONTACT hContact, PROTORECVEVENT *evt) override { CCSDATA ccs = { hContact, PSR_AUTH, 0, (LPARAM)evt }; return (int)ProtoCallService(m_szModuleName, PSR_AUTH, 0, (LPARAM)&ccs); } - virtual int AuthRequest(MCONTACT hContact, const wchar_t *szMessage) override + int AuthRequest(MCONTACT hContact, const wchar_t *szMessage) override { CCSDATA ccs = { hContact, PSS_AUTHREQUEST, 0, (LPARAM)szMessage }; if (m_iVersion > 1) @@ -93,7 +93,7 @@ struct DEFAULT_PROTO_INTERFACE : public PROTO_INTERFACE return res; } - virtual HANDLE FileAllow(MCONTACT hContact, HANDLE hTransfer, const wchar_t* szPath) override + HANDLE FileAllow(MCONTACT hContact, HANDLE hTransfer, const wchar_t* szPath) override { CCSDATA ccs = { hContact, PSS_FILEALLOW, (WPARAM)hTransfer, (LPARAM)szPath }; if (m_iVersion > 1) @@ -105,13 +105,13 @@ struct DEFAULT_PROTO_INTERFACE : public PROTO_INTERFACE return res; } - virtual int FileCancel(MCONTACT hContact, HANDLE hTransfer) override + int FileCancel(MCONTACT hContact, HANDLE hTransfer) override { CCSDATA ccs = { hContact, PSS_FILECANCEL, (WPARAM)hTransfer, 0 }; return (int)ProtoCallService(m_szModuleName, PSS_FILECANCEL, 0, (LPARAM)&ccs); } - virtual int FileDeny(MCONTACT hContact, HANDLE hTransfer, const wchar_t* szReason) override + int FileDeny(MCONTACT hContact, HANDLE hTransfer, const wchar_t* szReason) override { CCSDATA ccs = { hContact, PSS_FILEDENY, (WPARAM)hTransfer, (LPARAM)szReason }; if (m_iVersion > 1) @@ -137,18 +137,18 @@ struct DEFAULT_PROTO_INTERFACE : public PROTO_INTERFACE return res; } - virtual INT_PTR GetCaps(int type, MCONTACT hContact) override + INT_PTR GetCaps(int type, MCONTACT hContact) override { return ProtoCallService(m_szModuleName, PS_GETCAPS, type, hContact); } - virtual int GetInfo(MCONTACT hContact, int flags) override + int GetInfo(MCONTACT hContact, int flags) override { CCSDATA ccs = { hContact, PSS_GETINFO, (WPARAM)flags, 0 }; return ProtoCallService(m_szModuleName, PSS_GETINFO, 0, (LPARAM)&ccs); } - virtual HANDLE SearchBasic(const wchar_t* id) override + HANDLE SearchBasic(const wchar_t* id) override { if (m_iVersion > 1) return (HANDLE)ProtoCallService(m_szModuleName, PS_BASICSEARCH, 0, (LPARAM)id); @@ -156,14 +156,14 @@ struct DEFAULT_PROTO_INTERFACE : public PROTO_INTERFACE return (HANDLE)ProtoCallService(m_szModuleName, PS_BASICSEARCH, 0, _T2A(id)); } - virtual HANDLE SearchByEmail(const wchar_t* email) override + HANDLE SearchByEmail(const wchar_t* email) override { if (m_iVersion > 1) return (HANDLE)ProtoCallService(m_szModuleName, PS_SEARCHBYEMAIL, 0, (LPARAM)email); return (HANDLE)ProtoCallService(m_szModuleName, PS_SEARCHBYEMAIL, 0, _T2A(email)); } - virtual HANDLE SearchByName(const wchar_t* nick, const wchar_t* firstName, const wchar_t* lastName) override + HANDLE SearchByName(const wchar_t* nick, const wchar_t* firstName, const wchar_t* lastName) override { PROTOSEARCHBYNAME psn; psn.pszNick = (wchar_t*)mir_u2a(nick); @@ -177,48 +177,48 @@ struct DEFAULT_PROTO_INTERFACE : public PROTO_INTERFACE } - virtual HWND SearchAdvanced(HWND owner) override + HWND SearchAdvanced(HWND owner) override { return (HWND)ProtoCallService(m_szModuleName, PS_SEARCHBYADVANCED, 0, (LPARAM)owner); } - virtual HWND CreateExtendedSearchUI(HWND owner) override + HWND CreateExtendedSearchUI(HWND owner) override { return (HWND)ProtoCallService(m_szModuleName, PS_CREATEADVSEARCHUI, 0, (LPARAM)owner); } - virtual int RecvContacts(MCONTACT hContact, PROTORECVEVENT* evt) override + int RecvContacts(MCONTACT hContact, PROTORECVEVENT* evt) override { CCSDATA ccs = { hContact, PSR_CONTACTS, 0, (LPARAM)evt }; return (int)ProtoCallService(m_szModuleName, PSR_CONTACTS, 0, (LPARAM)&ccs); } - virtual int RecvFile(MCONTACT hContact, PROTORECVFILE* evt) override + int RecvFile(MCONTACT hContact, PROTORECVFILE* evt) override { CCSDATA ccs = { hContact, PSR_FILE, 0, (LPARAM)evt }; return ProtoCallService(m_szModuleName, PSR_FILE, 0, (LPARAM)&ccs); } - virtual int RecvMsg(MCONTACT hContact, PROTORECVEVENT* evt) override + int RecvMsg(MCONTACT hContact, PROTORECVEVENT* evt) override { CCSDATA ccs = { hContact, PSR_MESSAGE, 0, (LPARAM)evt }; INT_PTR res = ProtoCallService(m_szModuleName, PSR_MESSAGE, 0, (LPARAM)&ccs); return (res == CALLSERVICE_NOTFOUND) ? -1 : (int)res; } - virtual int RecvUrl(MCONTACT hContact, PROTORECVEVENT* evt) override + int RecvUrl(MCONTACT hContact, PROTORECVEVENT* evt) override { CCSDATA ccs = { hContact, PSR_URL, 0, (LPARAM)evt }; return (int)ProtoCallService(m_szModuleName, PSR_URL, 0, (LPARAM)&ccs); } - virtual int SendContacts(MCONTACT hContact, int flags, int nContacts, MCONTACT *hContactsList) override + int SendContacts(MCONTACT hContact, int flags, int nContacts, MCONTACT *hContactsList) override { CCSDATA ccs = { hContact, PSS_CONTACTS, MAKEWPARAM(flags, nContacts), (LPARAM)hContactsList }; return (int)ProtoCallService(m_szModuleName, PSS_CONTACTS, 0, (LPARAM)&ccs); } - virtual HANDLE SendFile(MCONTACT hContact, const wchar_t* szDescription, wchar_t** ppszFiles) override + HANDLE SendFile(MCONTACT hContact, const wchar_t* szDescription, wchar_t** ppszFiles) override { CCSDATA ccs = { hContact, PSS_FILE, (WPARAM)szDescription, (LPARAM)ppszFiles }; @@ -233,49 +233,49 @@ struct DEFAULT_PROTO_INTERFACE : public PROTO_INTERFACE return res; } - virtual int SendMsg(MCONTACT hContact, int /*flags*/, const char *msg) override + int SendMsg(MCONTACT hContact, int /*flags*/, const char *msg) override { CCSDATA ccs = { hContact, PSS_MESSAGE, 0, (LPARAM)msg }; return (int)ProtoCallService(m_szModuleName, PSS_MESSAGE, 0, (LPARAM)&ccs); } - virtual int SendUrl(MCONTACT hContact, int flags, const char* url) override + int SendUrl(MCONTACT hContact, int flags, const char* url) override { CCSDATA ccs = { hContact, PSS_URL, (WPARAM)flags, (LPARAM)url }; return (int)ProtoCallService(m_szModuleName, PSS_URL, 0, (LPARAM)&ccs); } - virtual int SetApparentMode(MCONTACT hContact, int mode) override + int SetApparentMode(MCONTACT hContact, int mode) override { CCSDATA ccs = { hContact, PSS_SETAPPARENTMODE, (WPARAM)mode, 0 }; return (int)ProtoCallService(m_szModuleName, PSS_SETAPPARENTMODE, 0, (LPARAM)&ccs); } - virtual int SetStatus(int iNewStatus) override + int SetStatus(int iNewStatus) override { return (int)ProtoCallService(m_szModuleName, PS_SETSTATUS, iNewStatus, 0); } - virtual HANDLE GetAwayMsg(MCONTACT hContact) override + HANDLE GetAwayMsg(MCONTACT hContact) override { CCSDATA ccs = { hContact, PSS_GETAWAYMSG, 0, 0 }; return (HANDLE)ProtoCallService(m_szModuleName, PSS_GETAWAYMSG, 0, (LPARAM)&ccs); } - virtual int RecvAwayMsg(MCONTACT hContact, int statusMode, PROTORECVEVENT* evt) override + int RecvAwayMsg(MCONTACT hContact, int statusMode, PROTORECVEVENT* evt) override { CCSDATA ccs = { hContact, PSR_AWAYMSG, (WPARAM)statusMode, (LPARAM)evt }; return (int)ProtoCallService(m_szModuleName, PSR_AWAYMSG, 0, (LPARAM)&ccs); } - virtual int SetAwayMsg(int iStatus, const wchar_t *msg) override + int SetAwayMsg(int iStatus, const wchar_t *msg) override { if (m_iVersion > 1) return (int)ProtoCallService(m_szModuleName, PS_SETAWAYMSG, iStatus, (LPARAM)msg); return (int)ProtoCallService(m_szModuleName, PS_SETAWAYMSG, iStatus, _T2A(msg)); } - virtual int UserIsTyping(MCONTACT hContact, int type) override + int UserIsTyping(MCONTACT hContact, int type) override { CCSDATA ccs = { hContact, PSS_USERISTYPING, hContact, type }; return ProtoCallService(m_szModuleName, PSS_USERISTYPING, 0, (LPARAM)&ccs); diff --git a/src/mir_app/src/proto_opts.cpp b/src/mir_app/src/proto_opts.cpp index a9a2ac15e0..85e7aa0947 100644 --- a/src/mir_app/src/proto_opts.cpp +++ b/src/mir_app/src/proto_opts.cpp @@ -113,9 +113,8 @@ class CAccountFormDlg : public CDlgBase public: CAccountFormDlg(CAccountManagerDlg *pParent, int action, PROTOACCOUNT *pa); - virtual void OnInitDialog() override; - - void OnOk(CCtrlButton*); + bool OnInitDialog() override; + bool OnApply() override; }; ///////////////////////////////////////////////////////////////////////////////////////// @@ -270,7 +269,7 @@ public: m_btnNetwork.OnClick = Callback(this, &CAccountManagerDlg::OnNetwork); } - virtual void OnInitDialog() override + bool OnInitDialog() override { Window_SetSkinIcon_IcoLib(m_hwnd, SKINICON_OTHER_ACCMGR); @@ -317,9 +316,10 @@ public: Refresh(); Utils_RestoreWindowPositionNoSize(m_hwnd, 0, "AccMgr", ""); + return true; } - virtual void OnApply() override + bool OnApply() override { PSHNOTIFY pshn; pshn.hdr.idFrom = 0; @@ -331,6 +331,7 @@ public: pa->bAccMgrUIChanged = FALSE; } } + return true; } virtual void OnReset() override @@ -347,7 +348,7 @@ public: } } - virtual void OnDestroy() override + void OnDestroy() override { for (auto &pa : accounts) { pa->bAccMgrUIChanged = FALSE; @@ -813,10 +814,9 @@ CAccountFormDlg::CAccountFormDlg(CAccountManagerDlg *pParent, int action, PROTOA m_pParent(pParent) { m_hwndParent = pParent->GetHwnd(); - m_btnOk.OnClick = Callback(this, &CAccountFormDlg::OnOk); } -void CAccountFormDlg::OnInitDialog() +bool CAccountFormDlg::OnInitDialog() { int cnt = 0; for (auto &it : g_arProtos) @@ -846,16 +846,17 @@ void CAccountFormDlg::OnInitDialog() } m_internalName.SendMsg(EM_LIMITTEXT, 40, 0); + return true; } -void CAccountFormDlg::OnOk(CCtrlButton*) +bool CAccountFormDlg::OnApply() { wchar_t tszAccName[256]; m_accName.GetText(tszAccName, _countof(tszAccName)); rtrimw(tszAccName); if (tszAccName[0] == 0) { MessageBox(m_hwnd, TranslateT("Account name must be filled."), TranslateT("Account error"), MB_ICONERROR | MB_OK); - return; + return false; } if (m_action == PRAC_ADDED) { @@ -863,7 +864,7 @@ void CAccountFormDlg::OnOk(CCtrlButton*) m_internalName.GetTextA(buf, _countof(buf)); if (FindAccountByName(rtrim(buf))) { MessageBox(m_hwnd, TranslateT("Account name has to be unique. Please enter unique name."), TranslateT("Account error"), MB_ICONERROR | MB_OK); - return; + return false; } } @@ -901,6 +902,7 @@ void CAccountFormDlg::OnOk(CCtrlButton*) m_pParent->Refresh(); EndModal(IDOK); + return true; } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/mir_app/src/proto_order.cpp b/src/mir_app/src/proto_order.cpp index 997f2b2a7b..a8f9017f45 100644 --- a/src/mir_app/src/proto_order.cpp +++ b/src/mir_app/src/proto_order.cpp @@ -158,12 +158,13 @@ public: m_order.OnDeleteItem = Callback(this, &CProtocolOrderOpts::onOrder_DeleteItem); } - virtual void OnInitDialog() override + bool OnInitDialog() override { FillTree(); + return true; } - virtual void OnApply() override + bool OnApply() override { // assume all accounts are disabled for (auto &it : accounts) @@ -201,6 +202,7 @@ public: Clist_TrayIconIconsChanged(); Clist_Broadcast(INTM_RELOADOPTIONS, 0, 0); Clist_Broadcast(INTM_INVALIDATE, 0, 0); + return true; } void onReset_Click(CCtrlButton*) diff --git a/src/mir_app/src/proto_ui.cpp b/src/mir_app/src/proto_ui.cpp index 2658436bd1..ca390845c5 100644 --- a/src/mir_app/src/proto_ui.cpp +++ b/src/mir_app/src/proto_ui.cpp @@ -94,17 +94,17 @@ INT_PTR CProtoIntDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) // Protocol events case WM_PROTO_ACTIVATE: OnProtoActivate(wParam, lParam); - return m_lresult; + return 0; case WM_PROTO_CHECK_ONLINE: if (m_hwndStatus) UpdateStatusBar(); OnProtoCheckOnline(wParam, lParam); - return m_lresult; + return 0; case WM_PROTO_REFRESH: OnProtoRefresh(wParam, lParam); - return m_lresult; + return 0; } return CSuper::DlgProc(msg, wParam, lParam); diff --git a/src/mir_app/src/skin2opts.cpp b/src/mir_app/src/skin2opts.cpp index 3d70ba3952..6347d5347c 100644 --- a/src/mir_app/src/skin2opts.cpp +++ b/src/mir_app/src/skin2opts.cpp @@ -177,8 +177,8 @@ public: m_preview.OnBeginDrag = Callback(this, &CIconImportDlg::OnBeginDragPreview); } - virtual void OnInitDialog() override; - virtual void OnClose() override; + bool OnInitDialog() override; + bool OnClose() override; virtual int Resizer(UTILRESIZECONTROL *urc) override { @@ -270,7 +270,7 @@ public: MySetCursor(IDC_ARROW); } - virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override; // forward declaration + INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override; // forward declaration }; ///////////////////////////////////////////////////////////////////////////////////////// @@ -563,7 +563,7 @@ public: m_categoryList.OnBuildMenu = Callback(this, &CIcoLibOptsDlg::OnTreeMenu); } - virtual void OnInitDialog() override + bool OnInitDialog() override { // Reset temporary data & upload sections list { @@ -584,9 +584,10 @@ public: m_preview.SetIconSpacing(56, 67); RebuildTree(); + return true; } - virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override + INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override { switch (msg) { case WM_NOTIFY: @@ -623,7 +624,7 @@ public: } } - virtual void OnApply() override + bool OnApply() override { { mir_cslock lck(csIconList); @@ -646,9 +647,10 @@ public: } DoIconsChanged(); + return true; } - virtual void OnDestroy() override + void OnDestroy() override { HTREEITEM hti = m_categoryList.GetRoot(); while (hti != nullptr) { @@ -821,7 +823,7 @@ public: ///////////////////////////////////////////////////////////////////////////////////////// -void CIconImportDlg::OnInitDialog() +bool CIconImportDlg::OnInitDialog() { m_preview.SetImageList(ImageList_Create(g_iIconSX, g_iIconSY, ILC_COLOR32 | ILC_MASK, 0, 100), LVSIL_NORMAL); m_preview.SetIconSpacing(56, 67); @@ -845,11 +847,13 @@ void CIconImportDlg::OnInitDialog() SHAutoComplete(m_iconSet.GetHwnd(), 1); m_iconSet.SetText(L"icons.dll"); + return true; } -void CIconImportDlg::OnClose() +bool CIconImportDlg::OnClose() { m_pParent->m_btnImport.Enable(); + return true; } INT_PTR CIconImportDlg::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp index ce7bf0d7c5..923b34f58f 100644 --- a/src/mir_app/src/srmm_base.cpp +++ b/src/mir_app/src/srmm_base.cpp @@ -630,7 +630,7 @@ LRESULT CSrmmBaseDialog::WndProc_Nicklist(UINT msg, WPARAM wParam, LPARAM lParam ///////////////////////////////////////////////////////////////////////////////////////// -void CSrmmBaseDialog::OnInitDialog() +bool CSrmmBaseDialog::OnInitDialog() { WindowList_Add(g_hWindowList, m_hwnd, m_hContact); SetWindowLongPtr(m_hwnd, GWLP_USERDATA, (LONG_PTR)this); @@ -653,6 +653,7 @@ void CSrmmBaseDialog::OnInitDialog() mir_subclassWindow(m_btnBkColor.GetHwnd(), Srmm_ButtonSubclassProc); LoadSettings(); + return true; } void CSrmmBaseDialog::OnDestroy() diff --git a/src/mir_app/src/srmm_toolbar.cpp b/src/mir_app/src/srmm_toolbar.cpp index caa774e09c..9f8f3e3aa1 100644 --- a/src/mir_app/src/srmm_toolbar.cpp +++ b/src/mir_app/src/srmm_toolbar.cpp @@ -620,7 +620,7 @@ public: m_btnSeparator.OnClick = Callback(this, &CSrmmToolbarOptions::btnSeparatorClicked); } - virtual void OnInitDialog() override + bool OnInitDialog() override { BuildMenuObjectsTree(); @@ -630,15 +630,16 @@ public: m_gap.SetRange(10); m_gap.SetPosition(db_get_b(0, BB_MODULE_NAME, "ButtonsBarGap", 1)); + return true; } - virtual void OnDestroy() override + void OnDestroy() override { ImageList_Destroy(m_toolBar.GetImageList(TVSIL_NORMAL)); ImageList_Destroy(m_toolBar.GetImageList(TVSIL_STATE)); } - virtual void OnApply() override + bool OnApply() override { OnTreeSelChanging(nullptr); // save latest changes SaveTree(); // save the whole tree then @@ -655,6 +656,7 @@ public: m_btnIM.Disable(); m_btnChat.Disable(); m_btnHidden.Disable(); + return true; } virtual void OnReset() override diff --git a/src/mir_core/src/CCtrlBase.cpp b/src/mir_core/src/CCtrlBase.cpp index 9901ce0c68..87f59e77c8 100644 --- a/src/mir_core/src/CCtrlBase.cpp +++ b/src/mir_core/src/CCtrlBase.cpp @@ -67,9 +67,10 @@ void CCtrlBase::OnDestroy() m_hwnd = nullptr; } -void CCtrlBase::OnApply() +bool CCtrlBase::OnApply() { m_bChanged = false; + return true; } void CCtrlBase::OnReset() diff --git a/src/mir_core/src/CCtrlCheck.cpp b/src/mir_core/src/CCtrlCheck.cpp index 5f220c6eba..3fe7fe2b15 100644 --- a/src/mir_core/src/CCtrlCheck.cpp +++ b/src/mir_core/src/CCtrlCheck.cpp @@ -35,12 +35,13 @@ BOOL CCtrlCheck::OnCommand(HWND, WORD, WORD) return TRUE; } -void CCtrlCheck::OnApply() +bool CCtrlCheck::OnApply() { CSuper::OnApply(); if (m_dbLink != nullptr) SaveInt(GetState()); + return true; } void CCtrlCheck::OnReset() diff --git a/src/mir_core/src/CCtrlCombo.cpp b/src/mir_core/src/CCtrlCombo.cpp index d8877ac82b..6854e841c3 100644 --- a/src/mir_core/src/CCtrlCombo.cpp +++ b/src/mir_core/src/CCtrlCombo.cpp @@ -51,7 +51,7 @@ void CCtrlCombo::OnInit() OnReset(); } -void CCtrlCombo::OnApply() +bool CCtrlCombo::OnApply() { CSuper::OnApply(); @@ -64,6 +64,7 @@ void CCtrlCombo::OnApply() else if (GetDataType() != DBVT_DELETED) { SaveInt(GetInt()); } + return true; } void CCtrlCombo::OnReset() diff --git a/src/mir_core/src/CCtrlEdit.cpp b/src/mir_core/src/CCtrlEdit.cpp index 7b821c2de2..1d08d665ac 100644 --- a/src/mir_core/src/CCtrlEdit.cpp +++ b/src/mir_core/src/CCtrlEdit.cpp @@ -36,7 +36,7 @@ BOOL CCtrlEdit::OnCommand(HWND, WORD, WORD idCode) return TRUE; } -void CCtrlEdit::OnApply() +bool CCtrlEdit::OnApply() { CSuper::OnApply(); @@ -49,6 +49,7 @@ void CCtrlEdit::OnApply() else if (GetDataType() != DBVT_DELETED) { SaveInt(GetInt()); } + return true; } void CCtrlEdit::OnReset() diff --git a/src/mir_core/src/CCtrlPages.cpp b/src/mir_core/src/CCtrlPages.cpp index d56231b796..39efe9e997 100644 --- a/src/mir_core/src/CCtrlPages.cpp +++ b/src/mir_core/src/CCtrlPages.cpp @@ -353,7 +353,7 @@ void CCtrlPages::OnReset() } } -void CCtrlPages::OnApply() +bool CCtrlPages::OnApply() { PSHNOTIFY pshn; pshn.hdr.idFrom = 0; @@ -362,10 +362,8 @@ void CCtrlPages::OnApply() if (m_pActivePage != nullptr) { pshn.hdr.code = PSN_KILLACTIVE; pshn.hdr.hwndFrom = m_pActivePage->GetHwnd(); - if (SendMessage(pshn.hdr.hwndFrom, WM_NOTIFY, 0, (LPARAM)&pshn)) { - m_parentWnd->Fail(); - return; - } + if (SendMessage(pshn.hdr.hwndFrom, WM_NOTIFY, 0, (LPARAM)&pshn)) + return false; } pshn.hdr.code = PSN_APPLY; @@ -383,12 +381,12 @@ void CCtrlPages::OnApply() m_pActivePage->Hide(); m_pActivePage = p->m_pDlg; m_pActivePage->Show(); - m_parentWnd->Fail(); - return; + return false; } } CSuper::OnApply(); + return true; } void CCtrlPages::OnDestroy() diff --git a/src/mir_core/src/CCtrlSpin.cpp b/src/mir_core/src/CCtrlSpin.cpp index f0af3c9609..a348b5c5e4 100644 --- a/src/mir_core/src/CCtrlSpin.cpp +++ b/src/mir_core/src/CCtrlSpin.cpp @@ -38,12 +38,13 @@ BOOL CCtrlSpin::OnNotify(int, NMHDR *pnmh) return FALSE; } -void CCtrlSpin::OnApply() +bool CCtrlSpin::OnApply() { CSuper::OnApply(); if (m_dbLink != nullptr) SaveInt(GetPosition()); + return true; } void CCtrlSpin::OnReset() diff --git a/src/mir_core/src/CDlgBase.cpp b/src/mir_core/src/CDlgBase.cpp index a92012e996..6bf0b703b4 100644 --- a/src/mir_core/src/CDlgBase.cpp +++ b/src/mir_core/src/CDlgBase.cpp @@ -51,10 +51,7 @@ CDlgBase::CDlgBase(CMPluginBase &pPlug, int idDialog) m_pPlugin(pPlug) { m_idDialog = idDialog; - m_hwnd = m_hwndParent = nullptr; - m_isModal = m_initialized = m_bExiting = false; m_autoClose = CLOSE_ON_OK | CLOSE_ON_CANCEL; - m_forceResizable = false; } CDlgBase::~CDlgBase() @@ -64,6 +61,36 @@ CDlgBase::~CDlgBase() DestroyWindow(m_hwnd); } +///////////////////////////////////////////////////////////////////////////////////////// +// events + +bool CDlgBase::OnInitDialog() +{ + return true; +} + +bool CDlgBase::OnClose() +{ + return true; +} + +bool CDlgBase::OnApply() +{ + return true; +} + +void CDlgBase::OnChange() +{} + +void CDlgBase::OnDestroy() +{} + +void CDlgBase::OnReset() +{} + +void CDlgBase::OnTimer(CTimer*) +{} + ///////////////////////////////////////////////////////////////////////////////////////// // methods @@ -181,7 +208,8 @@ INT_PTR CDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) ::EnumChildWindows(m_hwnd, &GlobalFieldEnum, LPARAM(this)); NotifyControls(&CCtrlBase::OnInit); - OnInitDialog(); + if (!OnInitDialog()) + return FALSE; m_initialized = true; return TRUE; @@ -244,16 +272,15 @@ INT_PTR CDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) // close dialog automatically if 'OK' button is pressed if (idCtrl == IDOK && (m_autoClose & CLOSE_ON_OK)) { // validate dialog data first - m_bExiting = true; - m_lresult = TRUE; - NotifyControls(&CCtrlBase::OnApply); - OnApply(); - - // everything ok? good, let's close it - if (m_lresult == TRUE) - PostMessage(m_hwnd, WM_CLOSE, 0, 0); - else - m_bExiting = false; + if (VerifyControls(&CCtrlBase::OnApply)) { + m_bExiting = true; + + // everything ok? good, let's close it + if (OnApply()) + PostMessage(m_hwnd, WM_CLOSE, 0, 0); + else + m_bExiting = false; + } } } } @@ -269,10 +296,10 @@ INT_PTR CDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) if (LPPSHNOTIFY(lParam)->lParam != 3) // IDC_APPLY m_bExiting = true; - m_lresult = true; - NotifyControls(&CCtrlBase::OnApply); - if (m_lresult) - OnApply(); + if (!VerifyControls(&CCtrlBase::OnApply)) + m_bExiting = false; + else if (!OnApply()) + m_bExiting = false; break; case PSN_RESET: @@ -312,10 +339,8 @@ INT_PTR CDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) return FALSE; case WM_CLOSE: - m_bExiting = true; - m_lresult = FALSE; - OnClose(); - if (!m_lresult) { + if (OnClose()) { + m_bExiting = true; if (m_isModal) EndModal(0); else @@ -384,6 +409,15 @@ void CDlgBase::NotifyControls(void (CCtrlBase::*fn)()) (it->*fn)(); } +bool CDlgBase::VerifyControls(bool (CCtrlBase::*fn)()) +{ + for (auto &it : m_controls) + if (!(it->*fn)()) + return false; + + return true; +} + CCtrlBase* CDlgBase::FindControl(int idCtrl) { CCtrlBase search(nullptr, idCtrl); diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index 678e5453e5..3c0afec46b 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -738,13 +738,13 @@ mir_wstrcmpi @280 ?MapIndexToID@CCtrlListView@@QAEII@Z @909 NONAME ?NotifyChange@CCtrlBase@@QAEXXZ @910 NONAME ?NotifyControls@CDlgBase@@AAEXP8CCtrlBase@@AEXXZ@Z @911 NONAME -?OnApply@CCtrlBase@@UAEXXZ @912 NONAME -?OnApply@CCtrlCheck@@UAEXXZ @913 NONAME -?OnApply@CCtrlCombo@@UAEXXZ @914 NONAME -?OnApply@CCtrlEdit@@UAEXXZ @915 NONAME -?OnApply@CDlgBase@@MAEXXZ @916 NONAME +?OnApply@CCtrlBase@@UAE_NXZ @912 NONAME +?OnApply@CCtrlCheck@@UAE_NXZ @913 NONAME +?OnApply@CCtrlCombo@@UAE_NXZ @914 NONAME +?OnApply@CCtrlEdit@@UAE_NXZ @915 NONAME +?OnApply@CDlgBase@@MAE_NXZ @916 NONAME ?OnChange@CDlgBase@@MAEXXZ @917 NONAME -?OnClose@CDlgBase@@MAEXXZ @918 NONAME +?OnClose@CDlgBase@@MAE_NXZ @918 NONAME ?OnCommand@CCtrlBase@@UAEHPAUHWND__@@GG@Z @919 NONAME ?OnCommand@CCtrlButton@@UAEHPAUHWND__@@GG@Z @920 NONAME ?OnCommand@CCtrlCheck@@UAEHPAUHWND__@@GG@Z @921 NONAME @@ -762,7 +762,7 @@ mir_wstrcmpi @280 ?OnInit@CCtrlData@@UAEXXZ @934 NONAME ?OnInit@CCtrlMButton@@UAEXXZ @936 NONAME ?OnInit@CCtrlPages@@MAEXXZ @937 NONAME -?OnInitDialog@CDlgBase@@MAEXXZ @938 NONAME +?OnInitDialog@CDlgBase@@MAE_NXZ @938 NONAME ?OnMeasureItem@CCtrlBase@@UAEHPAUtagMEASUREITEMSTRUCT@@@Z @939 NONAME ?OnNotify@CCtrlBase@@UAEHHPAUtagNMHDR@@@Z @940 NONAME ?OnNotify@CCtrlClc@@MAEHHPAUtagNMHDR@@@Z @941 NONAME @@ -907,8 +907,7 @@ mir_wstrcmpi @280 ?UnselectAll@CCtrlTreeView@@QAEXXZ @1093 NONAME ?MoveItemAbove@CCtrlTreeView@@AAEPAU_TREEITEM@@PAU2@00@Z @1094 NONAME ?GetCurrPage@CCtrlPages@@AAEPAUTPageInfo@1@XZ @1095 NONAME -?Fail@CDlgBase@@QAEXXZ @1096 NONAME -?OnApply@CCtrlPages@@MAEXXZ @1097 NONAME +?OnApply@CCtrlPages@@MAE_NXZ @1097 NONAME ?OnReset@CCtrlPages@@MAEXXZ @1098 NONAME Bitmap_GetFilter @1099 Bitmap_Load @1100 @@ -1055,7 +1054,7 @@ IsTerminalDisconnected @1245 ?OnDestroy@CCtrlTreeView@@MAEXXZ @1249 NONAME ?GetUrl@CCtrlHyperlink@@QAEPBDXZ @1250 NONAME ?IsChecked@CCtrlCheck@@QAE_NXZ @1251 NONAME -?OnApply@CCtrlSpin@@UAEXXZ @1252 NONAME +?OnApply@CCtrlSpin@@UAE_NXZ @1252 NONAME ?OnReset@CCtrlSpin@@UAEXXZ @1253 NONAME ?SetUrl@CCtrlHyperlink@@QAEXPBD@Z @1254 NONAME ?Default_OnClick@CCtrlHyperlink@@IAEXPAV1@@Z @1255 NONAME @@ -1068,3 +1067,4 @@ CallObjectEventHook @1259 ?CreateLink@CDlgBase@@IAEXAAVCCtrlData@@PBDEK@Z @1262 NONAME ?CreateLink@CDlgBase@@IAEXAAVCCtrlData@@PBDPA_W@Z @1263 NONAME ?CheckRowCount@CCtrlPages@@AAEXXZ @1264 NONAME +?VerifyControls@CDlgBase@@AAE_NP8CCtrlBase@@AE_NXZ@Z @1265 NONAME diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index f84202ff91..05064e9e3b 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -738,13 +738,13 @@ mir_wstrcmpi @280 ?MapIndexToID@CCtrlListView@@QEAAII@Z @909 NONAME ?NotifyChange@CCtrlBase@@QEAAXXZ @910 NONAME ?NotifyControls@CDlgBase@@AEAAXP8CCtrlBase@@EAAXXZ@Z @911 NONAME -?OnApply@CCtrlBase@@UEAAXXZ @912 NONAME -?OnApply@CCtrlCheck@@UEAAXXZ @913 NONAME -?OnApply@CCtrlCombo@@UEAAXXZ @914 NONAME -?OnApply@CCtrlEdit@@UEAAXXZ @915 NONAME -?OnApply@CDlgBase@@MEAAXXZ @916 NONAME +?OnApply@CCtrlBase@@UEAA_NXZ @912 NONAME +?OnApply@CCtrlCheck@@UEAA_NXZ @913 NONAME +?OnApply@CCtrlCombo@@UEAA_NXZ @914 NONAME +?OnApply@CCtrlEdit@@UEAA_NXZ @915 NONAME +?OnApply@CDlgBase@@MEAA_NXZ @916 NONAME ?OnChange@CDlgBase@@MEAAXXZ @917 NONAME -?OnClose@CDlgBase@@MEAAXXZ @918 NONAME +?OnClose@CDlgBase@@MEAA_NXZ @918 NONAME ?OnCommand@CCtrlBase@@UEAAHPEAUHWND__@@GG@Z @919 NONAME ?OnCommand@CCtrlButton@@UEAAHPEAUHWND__@@GG@Z @920 NONAME ?OnCommand@CCtrlCheck@@UEAAHPEAUHWND__@@GG@Z @921 NONAME @@ -762,7 +762,7 @@ mir_wstrcmpi @280 ?OnInit@CCtrlData@@UEAAXXZ @934 NONAME ?OnInit@CCtrlMButton@@UEAAXXZ @936 NONAME ?OnInit@CCtrlPages@@MEAAXXZ @937 NONAME -?OnInitDialog@CDlgBase@@MEAAXXZ @938 NONAME +?OnInitDialog@CDlgBase@@MEAA_NXZ @938 NONAME ?OnMeasureItem@CCtrlBase@@UEAAHPEAUtagMEASUREITEMSTRUCT@@@Z @939 NONAME ?OnNotify@CCtrlBase@@UEAAHHPEAUtagNMHDR@@@Z @940 NONAME ?OnNotify@CCtrlClc@@MEAAHHPEAUtagNMHDR@@@Z @941 NONAME @@ -907,8 +907,7 @@ mir_wstrcmpi @280 ?UnselectAll@CCtrlTreeView@@QEAAXXZ @1093 NONAME ?MoveItemAbove@CCtrlTreeView@@AEAAPEAU_TREEITEM@@PEAU2@00@Z @1094 NONAME ?GetCurrPage@CCtrlPages@@AEAAPEAUTPageInfo@1@XZ @1095 NONAME -?Fail@CDlgBase@@QEAAXXZ @1096 NONAME -?OnApply@CCtrlPages@@MEAAXXZ @1097 NONAME +?OnApply@CCtrlPages@@MEAA_NXZ @1097 NONAME ?OnReset@CCtrlPages@@MEAAXXZ @1098 NONAME Bitmap_GetFilter @1099 Bitmap_Load @1100 @@ -1056,7 +1055,7 @@ IsTerminalDisconnected @1245 ?Default_OnClick@CCtrlHyperlink@@IEAAXPEAV1@@Z @1250 NONAME ?GetUrl@CCtrlHyperlink@@QEAAPEBDXZ @1251 NONAME ?IsChecked@CCtrlCheck@@QEAA_NXZ @1252 NONAME -?OnApply@CCtrlSpin@@UEAAXXZ @1253 NONAME +?OnApply@CCtrlSpin@@UEAA_NXZ @1253 NONAME ?OnReset@CCtrlSpin@@UEAAXXZ @1254 NONAME ?SetUrl@CCtrlHyperlink@@QEAAXPEBD@Z @1255 NONAME ??0CCtrlLabel@@QEAA@PEAVCDlgBase@@H@Z @1256 NONAME @@ -1068,3 +1067,4 @@ CallObjectEventHook @1259 ?CreateLink@CDlgBase@@IEAAXAEAVCCtrlData@@PEBDEK@Z @1262 NONAME ?CreateLink@CDlgBase@@IEAAXAEAVCCtrlData@@PEBDPEA_W@Z @1263 NONAME ?CheckRowCount@CCtrlPages@@AEAAXXZ @1264 NONAME +?VerifyControls@CDlgBase@@AEAA_NP8CCtrlBase@@EAA_NXZ@Z @1265 NONAME -- cgit v1.2.3