diff options
author | George Hazan <ghazan@miranda.im> | 2018-04-20 19:47:15 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-04-20 19:47:15 +0300 |
commit | 9e9aded042fcf8b1d9806a3e59a45613d0099b71 (patch) | |
tree | e7772f4717a6ead115c266268c4a99fb618b6cfc /src | |
parent | d3124f6e5bee33b542e759fedd3792747122241b (diff) |
fix for setting container's name
Diffstat (limited to 'src')
-rw-r--r-- | src/core/stdmsg/src/chat_window.cpp | 6 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgdialog.cpp | 95 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgs.h | 3 |
3 files changed, 61 insertions, 43 deletions
diff --git a/src/core/stdmsg/src/chat_window.cpp b/src/core/stdmsg/src/chat_window.cpp index f6644e82df..8ae395baff 100644 --- a/src/core/stdmsg/src/chat_window.cpp +++ b/src/core/stdmsg/src/chat_window.cpp @@ -96,7 +96,7 @@ void CChatRoomDlg::onActivate() g_Settings.iWidth = wp.rcNormalPosition.right - wp.rcNormalPosition.left; g_Settings.iHeight = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top; - SendMessage(m_hwnd, DM_UPDATETITLE, 0, 0); + UpdateTitle(); pci->SetActiveSession(m_si); UpdateStatusBar(); @@ -1166,6 +1166,10 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) SetFocus(m_message.GetHwnd()); break; + case DM_UPDATETITLE: + UpdateTitle(); + break; + case DM_CLOSETAB: CloseTab(); break; diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index 53c8179620..cc656c7754 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -372,7 +372,7 @@ void CSrmmWindow::OnOptionsApplied(bool bUpdateAvatar) m_btnOk.Enable(GetWindowTextLength(m_message.GetHwnd()) != 0);
if (m_avatarPic == nullptr || !g_dat.bShowAvatar)
m_avatar.Hide();
- SendMessage(m_hwnd, DM_UPDATETITLE, 0, 0);
+ UpdateTitle();
Resize();
if (m_hBkgBrush)
@@ -576,6 +576,27 @@ void CSrmmWindow::SetStatusText(const wchar_t *wszText, HICON hIcon) SendMessage(m_pOwner->m_hwndStatus, SB_SETTEXT, 0, (LPARAM)(wszText == nullptr ? L"" : wszText));
}
+void CSrmmWindow::UpdateIcon(WPARAM wParam)
+{
+ if (!m_hContact || !m_szProto)
+ return;
+
+ DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)wParam;
+ if (!cws || (!mir_strcmp(cws->szModule, m_szProto) && !mir_strcmp(cws->szSetting, "Status"))) {
+ if (m_szProto) {
+ HICON hIcon = Skin_LoadProtoIcon(m_szProto, m_wStatus);
+ if (hIcon) {
+ if (m_hStatusIcon)
+ IcoLib_ReleaseIcon(m_hStatusIcon);
+ m_hStatusIcon = hIcon;
+ SendDlgItemMessage(m_hwnd, IDC_USERMENU, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
+ }
+ }
+ if (g_dat.bUseStatusWinIcon)
+ SendMessage(m_hwnd, DM_UPDATEWINICON, 0, 0);
+ }
+}
+
void CSrmmWindow::UpdateReadChars()
{
if (g_dat.bShowReadChar) {
@@ -587,6 +608,31 @@ void CSrmmWindow::UpdateReadChars() }
}
+void CSrmmWindow::UpdateTitle()
+{
+ wchar_t newtitle[256];
+ if (m_hContact && m_szProto) {
+ m_wStatus = db_get_w(m_hContact, m_szProto, "Status", ID_STATUS_OFFLINE);
+ wchar_t *contactName = Clist_GetContactDisplayName(m_hContact);
+
+ wchar_t *szStatus = Clist_GetStatusModeDescription(m_szProto == nullptr ? ID_STATUS_OFFLINE : db_get_w(m_hContact, m_szProto, "Status", ID_STATUS_OFFLINE), 0);
+ if (g_dat.bUseStatusWinIcon)
+ mir_snwprintf(newtitle, L"%s - %s", contactName, TranslateT("Message session"));
+ else
+ mir_snwprintf(newtitle, L"%s (%s): %s", contactName, szStatus, TranslateT("Message session"));
+
+ m_wOldStatus = m_wStatus;
+ }
+ else mir_wstrncpy(newtitle, TranslateT("Message session"), _countof(newtitle));
+
+ wchar_t oldtitle[256];
+ GetWindowText(m_hwnd, oldtitle, _countof(oldtitle));
+ if (mir_wstrcmp(newtitle, oldtitle)) { //swt() flickers even if the title hasn't actually changed
+ SetWindowText(m_pOwner->GetHwnd(), newtitle);
+ Resize();
+ }
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
int CSrmmWindow::Resizer(UTILRESIZECONTROL *urc)
@@ -1011,45 +1057,6 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) OnOptionsApplied(wParam != 0);
break;
- case DM_UPDATETITLE:
- wchar_t newtitle[256];
- if (m_hContact && m_szProto) {
- m_wStatus = db_get_w(m_hContact, m_szProto, "Status", ID_STATUS_OFFLINE);
- wchar_t *contactName = Clist_GetContactDisplayName(m_hContact);
-
- wchar_t *szStatus = Clist_GetStatusModeDescription(m_szProto == nullptr ? ID_STATUS_OFFLINE : db_get_w(m_hContact, m_szProto, "Status", ID_STATUS_OFFLINE), 0);
- if (g_dat.bUseStatusWinIcon)
- mir_snwprintf(newtitle, L"%s - %s", contactName, TranslateT("Message session"));
- else
- mir_snwprintf(newtitle, L"%s (%s): %s", contactName, szStatus, TranslateT("Message session"));
-
- DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)wParam;
- if (!cws || (!mir_strcmp(cws->szModule, m_szProto) && !mir_strcmp(cws->szSetting, "Status"))) {
- if (m_szProto) {
- HICON hIcon = Skin_LoadProtoIcon(m_szProto, m_wStatus);
- if (hIcon) {
- if (m_hStatusIcon)
- IcoLib_ReleaseIcon(m_hStatusIcon);
- m_hStatusIcon = hIcon;
- SendDlgItemMessage(m_hwnd, IDC_USERMENU, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
- }
- }
- if (g_dat.bUseStatusWinIcon)
- SendMessage(m_hwnd, DM_UPDATEWINICON, 0, 0);
- }
-
- m_wOldStatus = m_wStatus;
- }
- else mir_wstrncpy(newtitle, TranslateT("Message session"), _countof(newtitle));
-
- wchar_t oldtitle[256];
- GetWindowText(m_hwnd, oldtitle, _countof(oldtitle));
- if (mir_wstrcmp(newtitle, oldtitle)) { //swt() flickers even if the title hasn't actually changed
- SetWindowText(m_pOwner->GetHwnd(), newtitle);
- Resize();
- }
- break;
-
case DM_NEWTIMEZONE:
m_hTimeZone = TimeZone_CreateByContact(m_hContact, nullptr, TZF_KNOWNONLY);
m_wMinute = 61;
@@ -1076,7 +1083,7 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) SetFocus(m_message.GetHwnd());
// fall through
case WM_MOUSEACTIVATE:
- SendMessage(m_hwnd, DM_UPDATETITLE, 0, 0);
+ UpdateTitle();
if (KillTimer(m_hwnd, TIMERID_FLASHWND))
FlashWindow(m_pOwner->GetHwnd(), FALSE);
break;
@@ -1389,6 +1396,12 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) }
break;
+ case DM_UPDATETITLE:
+ if (wParam)
+ UpdateIcon(wParam);
+ UpdateTitle();
+ break;
+
case DM_CLOSETAB:
CloseTab();
break;
diff --git a/src/core/stdmsg/src/msgs.h b/src/core/stdmsg/src/msgs.h index 2c14795074..cc1c72b125 100644 --- a/src/core/stdmsg/src/msgs.h +++ b/src/core/stdmsg/src/msgs.h @@ -76,6 +76,7 @@ class CSrmmWindow : public CMsgDialog void ShowTime(void);
void SetupStatusBar(void);
void StreamInEvents(MEVENT hDbEventFirst, int count, bool bAppend);
+ void UpdateIcon(WPARAM wParam);
char *m_szProto;
HICON m_hStatusIcon = nullptr;
@@ -123,7 +124,7 @@ public: virtual void LoadSettings() override {}
virtual void ScrollToBottom() override;
virtual void SetStatusText(const wchar_t*, HICON) override;
- virtual void UpdateTitle() override {}
+ virtual void UpdateTitle() override;
void OnSplitterMoved(CSplitter*);
|