From c5ac09f8f9da22213e1471370f54343e12a139ac Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Wed, 26 Dec 2018 18:29:38 +0300 Subject: Fingerprint: crash fix (after move to m_gui) MenuEx: moved to m_gui --- plugins/MenuItemEx/res/resource.rc | 2 +- plugins/MenuItemEx/src/options.cpp | 160 ++++++++++++++++++++++--------------- plugins/MenuItemEx/src/resource.h | 1 - plugins/MenuItemEx/src/stdafx.h | 26 ++++++ 4 files changed, 122 insertions(+), 67 deletions(-) (limited to 'plugins/MenuItemEx') diff --git a/plugins/MenuItemEx/res/resource.rc b/plugins/MenuItemEx/res/resource.rc index 4def2672dc..77b5784eed 100644 --- a/plugins/MenuItemEx/res/resource.rc +++ b/plugins/MenuItemEx/res/resource.rc @@ -17,7 +17,7 @@ #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL -#pragma code_page(1250) +#pragma code_page(1251) ///////////////////////////////////////////////////////////////////////////// // diff --git a/plugins/MenuItemEx/src/options.cpp b/plugins/MenuItemEx/src/options.cpp index 13512fff96..7395585672 100644 --- a/plugins/MenuItemEx/src/options.cpp +++ b/plugins/MenuItemEx/src/options.cpp @@ -26,81 +26,111 @@ static const checkboxes[] = { { IDC_TRIMID, VF_TRIMID } }; -INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam) +COptDialog::COptDialog() : + CDlgBase(g_plugin, IDD_OPTIONS), + m_chkVis(this, IDC_VIS), + m_chkAlpha(this, IDC_SHOWALPHAICONS), + m_chkHide(this, IDC_HIDE), + m_chkIgnore(this, IDC_IGNORE), + m_chkProtos(this, IDC_PROTOS), + m_chkAdded(this, IDC_ADDED), + m_chkAuthReq(this, IDC_AUTHREQ), + m_chkRecvFiles(this, IDC_RECVFILES), + m_chkCopyIP(this, IDC_COPYIP), + m_chkCopyMirver(this, IDC_COPYMIRVER), + m_chkStatusMsg(this, IDC_STATUSMSG), + m_chkSMName(this, IDC_SMNAME), + m_chkCopyID(this, IDC_COPYID), + m_chkCopyIDName(this, IDC_COPYIDNAME), + m_chkShowID(this, IDC_SHOWID), + m_chkTrimID(this, IDC_TRIMID), + m_lblHint(this, IDC_HINT1), + m_chkIgnoreHide(this, IDC_IGNOREHIDE) { - DWORD flags = g_plugin.getDword("flags", vf_default); - wchar_t buffer[64] = { 0 }; - int i; - - switch (msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hdlg); - - for (auto &it : checkboxes) - CheckDlgButton(hdlg, it.idc, (flags & it.flag) ? BST_CHECKED : BST_UNCHECKED); - - if (bPopupService) { - for (i = 0; i < 4; i++) { - GetDlgItemText(hdlg, checkboxes[i].idc, buffer, (_countof(buffer) - 3)); - mir_wstrcat(buffer, L" *"); - SetDlgItemText(hdlg, checkboxes[i].idc, buffer); - } - } - else ShowWindow(GetDlgItem(hdlg, IDC_HINT1), SW_HIDE); - - SendMessage(hdlg, WM_USER + 50, 0, 0); - return 0; - - case WM_USER + 50: - EnableWindow(GetDlgItem(hdlg, IDC_SHOWALPHAICONS), IsDlgButtonChecked(hdlg, IDC_VIS) == BST_CHECKED); - EnableWindow(GetDlgItem(hdlg, IDC_IGNOREHIDE), IsDlgButtonChecked(hdlg, IDC_IGNORE) == BST_CHECKED); - EnableWindow(GetDlgItem(hdlg, IDC_COPYIDNAME), IsDlgButtonChecked(hdlg, IDC_COPYID) == BST_CHECKED); - EnableWindow(GetDlgItem(hdlg, IDC_SHOWID), IsDlgButtonChecked(hdlg, IDC_COPYID) == BST_CHECKED); - EnableWindow(GetDlgItem(hdlg, IDC_TRIMID), (IsDlgButtonChecked(hdlg, IDC_COPYID) == BST_CHECKED && IsDlgButtonChecked(hdlg, IDC_SHOWID) == BST_CHECKED)); - EnableWindow(GetDlgItem(hdlg, IDC_SMNAME), IsDlgButtonChecked(hdlg, IDC_STATUSMSG) == BST_CHECKED); - return 1; - - case WM_NOTIFY: - switch (((LPNMHDR)lparam)->code) { - case PSN_APPLY: - DWORD mod_flags = 0; - - for (auto &it : checkboxes) - mod_flags |= IsDlgButtonChecked(hdlg, it.idc) ? it.flag : 0; - - g_plugin.setDword("flags", mod_flags); - return 1; - } - break; - - case WM_COMMAND: - if (HIWORD(wparam) == BN_CLICKED && GetFocus() == (HWND)lparam) { - SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); - if (LOWORD(wparam) == IDC_VIS || - LOWORD(wparam) == IDC_IGNORE || - LOWORD(wparam) == IDC_COPYID || - LOWORD(wparam) == IDC_STATUSMSG || - LOWORD(wparam) == IDC_SHOWID) - { - SendMessage(hdlg, WM_USER + 50, 0, 0); - } + m_flags = g_plugin.getDword("flags", vf_default); + + m_chkVis.OnChange = Callback(this, &COptDialog::OnVisChange); + m_chkIgnore.OnChange = Callback(this, &COptDialog::OnIgnoreChange); + m_chkCopyID.OnChange = Callback(this, &COptDialog::OnCopyIDChange); + m_chkStatusMsg.OnChange = Callback(this, &COptDialog::OnStatusMsgChange); + m_chkShowID.OnChange = Callback(this, &COptDialog::OnShowIDChange); +} + +bool COptDialog::OnInitDialog() +{ + for (auto &it : checkboxes) { + CCtrlCheck &item = *(CCtrlCheck*)FindControl(it.idc); + item.SetState(m_flags & it.flag); + } + + if (bPopupService) { + for (int i = 0; i < 4; i++) { + CCtrlCheck &item = *(CCtrlCheck*)FindControl(checkboxes[i].idc); + CMStringW buffer; + buffer.Format(L"%s *", item.GetText()); + item.SetText(buffer); } - return 0; + } + else + m_lblHint.Hide(); - case WM_CLOSE: - EndDialog(hdlg, 0); - return 0; + EnableWindowChecks(); + return true; +} + +bool COptDialog::OnApply() +{ + DWORD mod_flags = 0; + + for (auto &it : checkboxes) { + CCtrlCheck &item = *(CCtrlCheck*)FindControl(it.idc); + mod_flags |= item.GetState() ? it.flag : 0; } - return 0; + + g_plugin.setDword("flags", mod_flags); + return true; +} + +void COptDialog::EnableWindowChecks() +{ + m_chkAlpha.Enable(m_chkVis.GetState()); + m_chkIgnoreHide.Enable(m_chkIgnore.GetState()); + m_chkCopyIDName.Enable(m_chkCopyID.GetState()); + m_chkShowID.Enable(m_chkCopyID.GetState()); + m_chkTrimID.Enable(m_chkCopyID.GetState() && m_chkShowID.GetState()); + m_chkSMName.Enable(m_chkStatusMsg.GetState()); +} + +void COptDialog::OnVisChange(CCtrlBase*) +{ + EnableWindowChecks(); +} + +void COptDialog::OnIgnoreChange(CCtrlBase*) +{ + EnableWindowChecks(); +} + +void COptDialog::OnCopyIDChange(CCtrlBase*) +{ + EnableWindowChecks(); +} + +void COptDialog::OnStatusMsgChange(CCtrlBase*) +{ + EnableWindowChecks(); +} + +void COptDialog::OnShowIDChange(CCtrlBase*) +{ + EnableWindowChecks(); } int OptionsInit(WPARAM wparam, LPARAM) { OPTIONSDIALOGPAGE odp = {}; - odp.position = 955000000; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS); odp.szTitle.a = MODULENAME; - odp.pfnDlgProc = OptionsProc; + odp.pDialog = new COptDialog; odp.szGroup.a = LPGEN("Customize"); odp.flags = ODPF_BOLDGROUPS; g_plugin.addOptions(wparam, &odp); diff --git a/plugins/MenuItemEx/src/resource.h b/plugins/MenuItemEx/src/resource.h index d14e68272a..d988ca88c4 100644 --- a/plugins/MenuItemEx/src/resource.h +++ b/plugins/MenuItemEx/src/resource.h @@ -35,7 +35,6 @@ #define IDC_SHOWID 1017 #define IDC_TRIMID 1018 #define IDC_IGNOREHIDE 1019 -#define IDC_STATIC -1 // Next default values for new objects // diff --git a/plugins/MenuItemEx/src/stdafx.h b/plugins/MenuItemEx/src/stdafx.h index 29b5add4d8..7c2d4d0aa6 100644 --- a/plugins/MenuItemEx/src/stdafx.h +++ b/plugins/MenuItemEx/src/stdafx.h @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -68,4 +69,29 @@ int OptionsInit(WPARAM, LPARAM); extern const int vf_default; +class COptDialog : public CDlgBase +{ +private: + DWORD m_flags; + + CCtrlCheck m_chkVis, m_chkAlpha, m_chkHide, m_chkIgnore, m_chkProtos, m_chkAdded, m_chkAuthReq, m_chkRecvFiles, m_chkCopyIP, m_chkCopyMirver, m_chkStatusMsg, + m_chkSMName, m_chkCopyID, m_chkCopyIDName, m_chkShowID, m_chkTrimID, m_chkIgnoreHide; + CCtrlLabel m_lblHint; + +protected: + bool OnInitDialog() override; + bool OnApply() override; + + void OnVisChange(CCtrlBase*); + void OnIgnoreChange(CCtrlBase*); + void OnCopyIDChange(CCtrlBase*); + void OnStatusMsgChange(CCtrlBase*); + void OnShowIDChange(CCtrlBase*); + + void EnableWindowChecks(); + +public: + COptDialog(); +}; + #endif -- cgit v1.2.3