summaryrefslogtreecommitdiff
path: root/plugins/CurrencyRates/src/WinCtrlHelper.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-02-15 12:31:26 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-02-15 12:31:26 +0300
commitd061852f027e57625d7bdfd445469d9a29b1eb07 (patch)
tree3911c297149ed0f097c3db91253c0f4120eb0d17 /plugins/CurrencyRates/src/WinCtrlHelper.cpp
parent0ad0b41c6c42e0a346a7755de39dd03d4f25142d (diff)
CurrencyRates: code cleaning
Diffstat (limited to 'plugins/CurrencyRates/src/WinCtrlHelper.cpp')
-rw-r--r--plugins/CurrencyRates/src/WinCtrlHelper.cpp51
1 files changed, 21 insertions, 30 deletions
diff --git a/plugins/CurrencyRates/src/WinCtrlHelper.cpp b/plugins/CurrencyRates/src/WinCtrlHelper.cpp
index 636b7ae9b1..1b2daf3cb7 100644
--- a/plugins/CurrencyRates/src/WinCtrlHelper.cpp
+++ b/plugins/CurrencyRates/src/WinCtrlHelper.cpp
@@ -1,40 +1,31 @@
#include "stdafx.h"
-static INT_PTR CALLBACK VariableListDlgProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
+class CVariableListDlg : public CDlgBase
{
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hWnd);
- {
- const ICurrencyRatesProvider* pProvider = reinterpret_cast<const ICurrencyRatesProvider*>(lp);
- CCurrencyRatesProviderVisitorFormatSpecificator visitor;
- pProvider->Accept(visitor);
+ const ICurrencyRatesProvider *m_pProvider;
- tostringstream o;
- const CCurrencyRatesProviderVisitorFormatSpecificator::TFormatSpecificators& raSpec = visitor.GetSpecificators();
- std::for_each(raSpec.begin(), raSpec.end(),
- [&o](const CCurrencyRatesProviderVisitorFormatSpecificator::CFormatSpecificator& spec)
- {
- o << spec.m_sSymbol << '\t' << spec.m_sDesc << L"\r\n";
- });
- ::SetDlgItemText(hWnd, IDC_EDIT_VARIABLE, o.str().c_str());
- }
- break;
-
- case WM_COMMAND:
- if (BN_CLICKED == HIWORD(wp) && (IDOK == LOWORD(wp) || IDCANCEL == LOWORD(wp)))
- ::EndDialog(hWnd, IDOK);
- break;
+public:
+ CVariableListDlg(HWND hwndParent, const ICurrencyRatesProvider *pProvider) :
+ CDlgBase(g_plugin, IDD_DIALOG_VARIABLE_LIST),
+ m_pProvider(pProvider)
+ {
+ SetParent(hwndParent);
}
- return FALSE;
-}
+ bool OnInitDialog() override
+ {
+ CCurrencyRatesProviderVisitorFormatSpecificator visitor;
+ m_pProvider->Accept(visitor);
+
+ tostringstream o;
+ for (auto &spec : visitor.GetSpecificators())
+ o << spec.m_sSymbol << '\t' << spec.m_sDesc << L"\r\n";
+ ::SetDlgItemText(m_hwnd, IDC_EDIT_VARIABLE, o.str().c_str());
+ return true;
+ }
+};
void show_variable_list(HWND hwndParent, const ICurrencyRatesProvider* pProvider)
{
- ::DialogBoxParam(g_plugin.getInst(),
- MAKEINTRESOURCE(IDD_DIALOG_VARIABLE_LIST),
- hwndParent,
- VariableListDlgProc,
- reinterpret_cast<LPARAM>(pProvider));
+ CVariableListDlg(hwndParent, pProvider).DoModal();
}