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/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 +- 24 files changed, 328 insertions(+), 328 deletions(-) (limited to 'src/mir_app') 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 -- cgit v1.2.3