From f34a9cbf015c2bb6bd6359c7f68aa0d26656c4f3 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 15 Sep 2019 14:22:18 +0300 Subject: fixes #2051 (TabSRMM: group chats icon) --- plugins/TabSRMM/src/generic_msghandlers.cpp | 6 +++--- plugins/TabSRMM/src/msgdialog.cpp | 27 +++++---------------------- plugins/TabSRMM/src/msgdlgother.cpp | 27 ++++++++++++++++++++++++++- plugins/TabSRMM/src/msgs.h | 4 ++-- 4 files changed, 36 insertions(+), 28 deletions(-) (limited to 'plugins/TabSRMM/src') diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp index 2d2ff4ef23..6340d1a13d 100644 --- a/plugins/TabSRMM/src/generic_msghandlers.cpp +++ b/plugins/TabSRMM/src/generic_msghandlers.cpp @@ -977,7 +977,7 @@ void CMsgDialog::DM_OptionsApplied(WPARAM, LPARAM lParam) ShowWindow(m_hwndPanelPicParent, SW_SHOW); EnableWindow(m_hwndPanelPicParent, TRUE); - SendMessage(m_hwnd, DM_UPDATEWINICON, 0, 0); + UpdateWindowIcon(); } void CMsgDialog::DM_Typing(bool fForceOff) @@ -992,7 +992,7 @@ void CMsgDialog::DM_Typing(bool fForceOff) if (m_nTypeSecs > 0) { m_nTypeSecs--; if (GetForegroundWindow() == hwndContainer) - SendMessage(m_hwnd, DM_UPDATEWINICON, 0, 0); + UpdateWindowIcon(); } else { if (!fForceOff) { @@ -1003,7 +1003,7 @@ void CMsgDialog::DM_Typing(bool fForceOff) if (hwndStatus && m_pContainer->m_hwndActive == m_hwnd) SendMessage(hwndStatus, SB_SETTEXT, 0, (LPARAM)m_wszStatusBar); } - SendMessage(m_hwnd, DM_UPDATEWINICON, 0, 0); + UpdateWindowIcon(); HandleIconFeedback(this, (HICON)-1); CMsgDialog *dat_active = (CMsgDialog*)GetWindowLongPtr(m_pContainer->m_hwndActive, GWLP_USERDATA); if (dat_active && !dat_active->isChat()) diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index 17c7e99bfd..dfa226d46b 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -487,7 +487,7 @@ bool CMsgDialog::OnInitDialog() m_hHistoryEvents = nullptr; if (!m_bIsMeta) - SendMessage(m_hwnd, DM_UPDATEWINICON, 0, 0); + UpdateWindowIcon(); GetMyNick(); @@ -660,7 +660,8 @@ bool CMsgDialog::OnInitDialog() dbei.eventType = EVENTTYPE_MESSAGE; FlashOnClist(m_hDbEventFirst, &dbei); - m_pContainer->SetIcon(this, Skin_LoadIcon(SKINICON_EVENT_MESSAGE)); + if (!isChat()) + m_pContainer->SetIcon(this, Skin_LoadIcon(SKINICON_EVENT_MESSAGE)); m_pContainer->m_dwFlags |= CNT_NEED_UPDATETITLE; m_dwFlags |= MWF_NEEDCHECKSIZE | MWF_WASBACKGROUNDCREATE | MWF_DEFERREDSCROLL; } @@ -2819,25 +2820,7 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) return TRUE; case DM_UPDATEWINICON: - if (m_hXStatusIcon) { - DestroyIcon(m_hXStatusIcon); - m_hXStatusIcon = nullptr; - } - - if (LPCSTR szProto = m_cache->getProto()) { - m_hTabIcon = m_hTabStatusIcon = GetMyContactIcon("MetaiconTab"); - if (M.GetByte("use_xicons", 1)) - m_hXStatusIcon = GetXStatusIcon(); - - SendDlgItemMessage(m_hwnd, IDC_PROTOCOL, BUTTONSETASDIMMED, (m_dwFlagsEx & MWF_SHOW_ISIDLE) != 0, 0); - SendDlgItemMessage(m_hwnd, IDC_PROTOCOL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)(m_hXStatusIcon ? m_hXStatusIcon : GetMyContactIcon("MetaiconBar"))); - - if (m_pContainer->m_hwndActive == m_hwnd) - m_pContainer->SetIcon(this, m_hXStatusIcon ? m_hXStatusIcon : m_hTabIcon); - - if (m_pWnd) - m_pWnd->updateIcon(m_hXStatusIcon ? m_hXStatusIcon : m_hTabIcon); - } + UpdateWindowIcon(); return 0; case DM_CONFIGURETOOLBAR: @@ -2863,7 +2846,7 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) } Srmm_UpdateToolbarIcons(m_hwnd); - SendMessage(m_hwnd, DM_UPDATEWINICON, 0, 0); + UpdateWindowIcon(); return 0; case DM_OPTIONSAPPLIED: diff --git a/plugins/TabSRMM/src/msgdlgother.cpp b/plugins/TabSRMM/src/msgdlgother.cpp index 7dd848bec1..77e6e612ea 100644 --- a/plugins/TabSRMM/src/msgdlgother.cpp +++ b/plugins/TabSRMM/src/msgdlgother.cpp @@ -2350,7 +2350,7 @@ void CMsgDialog::UpdateTitle() else if (m_wStatus != m_wOldStatus) bChanged = true; - SendMessage(m_hwnd, DM_UPDATEWINICON, 0, 0); + UpdateWindowIcon(); wchar_t fulluin[256]; if (m_bIsMeta) @@ -2405,6 +2405,31 @@ void CMsgDialog::UpdateTitle() } } +///////////////////////////////////////////////////////////////////////////////////////// + +void CMsgDialog::UpdateWindowIcon() +{ + if (m_hXStatusIcon) { + DestroyIcon(m_hXStatusIcon); + m_hXStatusIcon = nullptr; + } + + if (LPCSTR szProto = m_cache->getProto()) { + m_hTabIcon = m_hTabStatusIcon = GetMyContactIcon("MetaiconTab"); + if (M.GetByte("use_xicons", 1)) + m_hXStatusIcon = GetXStatusIcon(); + + SendDlgItemMessage(m_hwnd, IDC_PROTOCOL, BUTTONSETASDIMMED, (m_dwFlagsEx & MWF_SHOW_ISIDLE) != 0, 0); + SendDlgItemMessage(m_hwnd, IDC_PROTOCOL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)(m_hXStatusIcon ? m_hXStatusIcon : GetMyContactIcon("MetaiconBar"))); + + if (m_pContainer->m_hwndActive == m_hwnd) + m_pContainer->SetIcon(this, m_hXStatusIcon ? m_hXStatusIcon : m_hTabIcon); + + if (m_pWnd) + m_pWnd->updateIcon(m_hXStatusIcon ? m_hXStatusIcon : m_hTabIcon); + } +} + ///////////////////////////////////////////////////////////////////////////////////////// // called whenever a group chat tab becomes active(either by switching tabs or activating a // container window diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h index 49dae11106..3ff66d0a7f 100644 --- a/plugins/TabSRMM/src/msgs.h +++ b/plugins/TabSRMM/src/msgs.h @@ -274,6 +274,8 @@ class CMsgDialog : public CSrmmBaseDialog void ResizeIeView(void); void SaveAvatarToFile(HBITMAP hbm, int isOwnPic); void ShowPopupMenu(const CCtrlBase&, POINT pt); + void UpdateWindowIcon(void); + void UpdateWindowState(UINT msg); void VerifyProxy(void); LRESULT WMCopyHandler(UINT uMsg, WPARAM wParam, LPARAM lParam); @@ -416,8 +418,6 @@ public: void OnDestroy() override; int Resizer(UTILRESIZECONTROL *urc) override; - void UpdateWindowState(UINT msg); - INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override; LRESULT WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam) override; LRESULT WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) override; -- cgit v1.2.3