diff options
author | George Hazan <ghazan@miranda.im> | 2017-03-03 18:08:16 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-03-03 18:08:16 +0300 |
commit | 1be16f1566b862629878a2d1a46063afeae78c38 (patch) | |
tree | 3717a30de15c1f3ae5e9326f80e799840db77c29 | |
parent | f4f859003e2d17ab6d457e552ccdde775899b328 (diff) |
fix for the shitty idea of all pre-created button objects' manual initialization
-rw-r--r-- | include/m_gui.h | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/window.cpp | 27 | ||||
-rw-r--r-- | src/core/stdmsg/src/chat_window.cpp | 3 | ||||
-rw-r--r-- | src/mir_app/src/srmm_toolbar.cpp | 9 |
4 files changed, 22 insertions, 19 deletions
diff --git a/include/m_gui.h b/include/m_gui.h index 67ea96ae4b..b1b30af2ae 100644 --- a/include/m_gui.h +++ b/include/m_gui.h @@ -396,6 +396,8 @@ public: __forceinline void SetParent(HWND hwnd) { m_hwndParent = hwnd; }
__forceinline void Close() { SendMessage(m_hwnd, WM_CLOSE, 0, 0); }
__forceinline void Fail() { m_lresult = false; }
+
+ __forceinline CCtrlBase* operator[](int iControlId) { return FindControl(iControlId); }
static CDlgBase* Find(HWND hwnd);
diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index fc69c6d6fa..cdefb49389 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -152,9 +152,6 @@ void CChatRoomDlg::UpdateWindowState(UINT msg) if (si == NULL) return; - HWND hwndDlg = GetHwnd(); - HWND hwndTab = GetParent(hwndDlg); - if (msg == WM_ACTIVATE) { if (m_pContainer->dwFlags & CNT_TRANSPARENCY) { DWORD trans = LOWORD(m_pContainer->settings->dwTransparency); @@ -176,7 +173,7 @@ void CChatRoomDlg::UpdateWindowState(UINT msg) if (m_bIsAutosizingInput && m_iInputAreaHeight == -1) { m_iInputAreaHeight = 0; - SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_REQUESTRESIZE, 0, 0); + SendDlgItemMessage(m_hwnd, IDC_MESSAGE, EM_REQUESTRESIZE, 0, 0); } m_pPanel->dismissConfig(); @@ -186,10 +183,10 @@ void CChatRoomDlg::UpdateWindowState(UINT msg) m_pWnd->setOverlayIcon(0, true); } - if (m_pContainer->hwndSaved == hwndDlg || m_bWasDeleted) + if (m_pContainer->hwndSaved == m_hwnd || m_bWasDeleted) return; - m_pContainer->hwndSaved = hwndDlg; + m_pContainer->hwndSaved = m_hwnd; pci->SetActiveSession(si->ptszID, si->pszModule); m_hTabIcon = m_hTabStatusIcon; @@ -200,10 +197,10 @@ void CChatRoomDlg::UpdateWindowState(UINT msg) if (pcli->pfnGetEvent(si->hContact, 0)) pcli->pfnRemoveEvent(si->hContact, GC_FAKE_EVENT); - SendMessage(hwndDlg, GC_UPDATETITLE, 0, 1); + SendMessage(m_hwnd, GC_UPDATETITLE, 0, 1); m_dwTickLastEvent = 0; m_dwFlags &= ~MWF_DIVIDERSET; - if (KillTimer(hwndDlg, TIMERID_FLASHWND) || m_iFlashIcon) { + if (KillTimer(m_hwnd, TIMERID_FLASHWND) || m_iFlashIcon) { FlashTab(false); m_bCanFlashTab = FALSE; m_iFlashIcon = 0; @@ -215,15 +212,15 @@ void CChatRoomDlg::UpdateWindowState(UINT msg) m_pContainer->dwFlags &= ~CNT_NEED_UPDATETITLE; if (m_dwFlags & MWF_NEEDCHECKSIZE) - PostMessage(hwndDlg, DM_SAVESIZE, 0, 0); + PostMessage(m_hwnd, DM_SAVESIZE, 0, 0); if (PluginConfig.m_bAutoLocaleSupport) { if (hkl == 0) DM_LoadLocale(); else - SendMessage(hwndDlg, DM_SETLOCALE, 0, 0); + SendMessage(m_hwnd, DM_SETLOCALE, 0, 0); } - SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGE)); + SetFocus(GetDlgItem(m_hwnd, IDC_MESSAGE)); m_dwLastActivity = GetTickCount(); m_pContainer->dwLastActivity = m_dwLastActivity; m_pContainer->MenuBar->configureMenu(); @@ -233,14 +230,14 @@ void CChatRoomDlg::UpdateWindowState(UINT msg) if (m_dwFlagsEx & MWF_EX_DELAYEDSPLITTER) { m_dwFlagsEx &= ~MWF_EX_DELAYEDSPLITTER; ShowWindow(m_pContainer->hwnd, SW_RESTORE); - PostMessage(hwndDlg, DM_SPLITTERGLOBALEVENT, m_wParam, m_lParam); - PostMessage(hwndDlg, WM_SIZE, 0, 0); + PostMessage(m_hwnd, DM_SPLITTERGLOBALEVENT, m_wParam, m_lParam); + PostMessage(m_hwnd, WM_SIZE, 0, 0); m_wParam = m_lParam = 0; } } BB_SetButtonsPos(); if (M.isAero()) - InvalidateRect(hwndTab, NULL, FALSE); + InvalidateRect(m_hwndParent, NULL, FALSE); if (m_pContainer->dwFlags & CNT_SIDEBAR) m_pContainer->SideBar->setActiveItem(this); @@ -1642,8 +1639,6 @@ void CChatRoomDlg::OnInitDialog() DM_InitTip(); BB_InitDlgButtons(); SendMessage(m_hwnd, WM_CBD_LOADICONS, 0, 0); - m_btnBold.OnInit(); m_btnItalic.OnInit(); m_btnUnderline.OnInit(); m_btnOk.OnInit(); - m_btnColor.OnInit(); m_btnBkColor.OnInit(); m_btnFilter.OnInit(); mir_subclassWindow(GetDlgItem(m_hwnd, IDC_SPLITTERX), SplitterSubclassProc); mir_subclassWindow(GetDlgItem(m_hwnd, IDC_SPLITTERY), SplitterSubclassProc); diff --git a/src/core/stdmsg/src/chat_window.cpp b/src/core/stdmsg/src/chat_window.cpp index f2391f0d42..128daf3b36 100644 --- a/src/core/stdmsg/src/chat_window.cpp +++ b/src/core/stdmsg/src/chat_window.cpp @@ -907,9 +907,6 @@ void CChatRoomDlg::OnInitDialog() // initialize toolbar icons Srmm_CreateToolbarIcons(m_hwnd, BBBF_ISCHATBUTTON); - m_btnBold.OnInit(); m_btnItalic.OnInit(); m_btnUnderline.OnInit(); - m_btnColor.OnInit(); m_btnBkColor.OnInit(); - m_btnFilter.OnInit(); m_btnHistory.OnInit(); m_btnChannelMgr.OnInit(); WindowList_Add(pci->hWindowList, m_hwnd, m_hContact); diff --git a/src/mir_app/src/srmm_toolbar.cpp b/src/mir_app/src/srmm_toolbar.cpp index 26523fbe01..b94c175ef0 100644 --- a/src/mir_app/src/srmm_toolbar.cpp +++ b/src/mir_app/src/srmm_toolbar.cpp @@ -320,6 +320,8 @@ MIR_APP_DLL(void) Srmm_CreateToolbarIcons(HWND hwndDlg, int flags) { HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtr(hwndDlg, GWLP_HINSTANCE); + CDlgBase *pDlg = CDlgBase::Find(hwndDlg); + for (int i = 0; i < arButtonsList.getCount(); i++) { CustomButtonData *cbd = arButtonsList[i]; if (cbd->m_bSeparator) @@ -331,6 +333,13 @@ MIR_APP_DLL(void) Srmm_CreateToolbarIcons(HWND hwndDlg, int flags) hwndButton = CreateWindowEx(0, L"MButtonClass", L"", WS_CHILD | WS_VISIBLE | WS_TABSTOP, 0, 0, cbd->m_iButtonWidth, DPISCALEX_S(22), hwndDlg, (HMENU)cbd->m_dwButtonCID, hInstance, NULL); if (hwndButton == NULL) // smth went wrong continue; + + // if there's a pre-created button control in a class, initialize it + if (pDlg != nullptr) { + CCtrlBase *pControl = (*pDlg)[cbd->m_dwButtonCID]; + if (pControl) + pControl->OnInit(); + } } SendMessage(hwndButton, BUTTONSETASFLATBTN, TRUE, 0); if (cbd->m_pwszText) |