diff options
-rw-r--r-- | src/core/stdmsg/src/msgs.cpp | 35 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgs.h | 4 | ||||
-rw-r--r-- | src/core/stdmsg/src/stdafx.h | 4 | ||||
-rw-r--r-- | src/core/stdmsg/src/tabs.cpp | 4 |
4 files changed, 27 insertions, 20 deletions
diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp index 3598683f88..077504cfe0 100644 --- a/src/core/stdmsg/src/msgs.cpp +++ b/src/core/stdmsg/src/msgs.cpp @@ -83,38 +83,38 @@ static int MessageEventAdded(WPARAM hContact, LPARAM hDbEvent) bPopup = true;
/* does a window for the contact exist? */
- HWND hwndContainer = 0;
- HWND hwndSrmm = Srmm_FindWindow(hContact);
- if (!hwndSrmm) {
- if (bPopup)
- hwndContainer = GetContainer()->AddPage(hContact, nullptr, true)->GetHwnd();
+ CTabbedWindow *pContainer = nullptr;
+ auto *pDlg = Srmm_FindDialog(hContact);
+ if (!pDlg) {
+ if (bPopup) {
+ pDlg = GetContainer()->AddPage(hContact, nullptr, true);
+ pContainer = pDlg->getContainer();
+ }
+
Skin_PlaySound("AlertMsg");
Srmm_AddEvent(hContact, hDbEvent);
}
else {
- hwndContainer = GetParent(hwndSrmm);
+ pContainer = pDlg->getContainer();
if (bPopup)
- ShowWindow(hwndContainer, SW_RESTORE);
+ ShowWindow(pContainer->GetHwnd(), SW_RESTORE);
- CTabbedWindow *pOwner = (CTabbedWindow *)GetWindowLongPtr(hwndContainer, GWLP_USERDATA);
- if (pOwner && pOwner->CurrPage()->GetHwnd() != hwndSrmm)
+ if (pContainer->CurrPage() != pDlg)
Srmm_AddEvent(hContact, hDbEvent);
}
- if (!hwndContainer)
+ if (!pContainer)
return 0;
- if (bPopup && g_Settings.bTabsEnable && GetForegroundWindow() != hwndContainer) {
- CSrmmBaseDialog *pDlg = (CSrmmBaseDialog*)GetWindowLongPtr(hwndSrmm ? hwndSrmm : Srmm_FindWindow(hContact), GWLP_USERDATA);
+ if (bPopup && g_Settings.bTabsEnable && GetForegroundWindow() != pContainer->GetHwnd())
g_pTabDialog->m_tab.ActivatePage(g_pTabDialog->m_tab.GetDlgIndex(pDlg));
- }
if (!g_plugin.bDoNotStealFocus) {
- SetForegroundWindow(hwndContainer);
+ SetForegroundWindow(pContainer->GetHwnd());
Skin_PlaySound("RecvMsgActive");
}
else {
- if (GetForegroundWindow() == GetParent(hwndContainer))
+ if (GetForegroundWindow() == GetParent(pContainer->GetHwnd()))
Skin_PlaySound("RecvMsgActive");
else
Skin_PlaySound("RecvMsgInactive");
@@ -150,7 +150,10 @@ INT_PTR SendMessageCmd(MCONTACT hContact, wchar_t *pwszInitialText) g_pTabDialog->m_tab.ActivatePage(g_pTabDialog->m_tab.GetDlgIndex(pDlg));
}
}
- else hwndContainer = GetContainer()->AddPage(hContact, pwszInitialText, false)->GetHwnd();
+ else {
+ auto *pDlg = GetContainer()->AddPage(hContact, pwszInitialText, false);
+ hwndContainer = pDlg->getContainer()->GetHwnd();
+ }
ShowWindow(hwndContainer, SW_RESTORE);
return 0;
diff --git a/src/core/stdmsg/src/msgs.h b/src/core/stdmsg/src/msgs.h index 416db5bf84..9a72a2ca55 100644 --- a/src/core/stdmsg/src/msgs.h +++ b/src/core/stdmsg/src/msgs.h @@ -139,6 +139,10 @@ public: return ((CLogWindow *)m_pLog);
}
+ __forceinline CTabbedWindow* getContainer() const {
+ return m_pOwner;
+ }
+
int m_avatarWidth = 0, m_avatarHeight = 0;
bool m_bIsAutoRTL = false;
diff --git a/src/core/stdmsg/src/stdafx.h b/src/core/stdmsg/src/stdafx.h index 10f410c451..147023d023 100644 --- a/src/core/stdmsg/src/stdafx.h +++ b/src/core/stdmsg/src/stdafx.h @@ -98,8 +98,8 @@ public: return GetActiveWindow() == m_hwnd && GetForegroundWindow() == m_hwnd;
}
- CTabbedWindow *AddPage(MCONTACT hContact, wchar_t *pwszText = nullptr, int iNoActivate = -1);
- CMsgDialog *CurrPage() const;
+ CMsgDialog* AddPage(MCONTACT hContact, wchar_t *pwszText = nullptr, int iNoActivate = -1);
+ CMsgDialog* CurrPage() const;
void AddPage(SESSION_INFO*, int insertAt = -1);
void DropTab(int begin, int end);
diff --git a/src/core/stdmsg/src/tabs.cpp b/src/core/stdmsg/src/tabs.cpp index 3ac74d75f8..f1eb1a4f32 100644 --- a/src/core/stdmsg/src/tabs.cpp +++ b/src/core/stdmsg/src/tabs.cpp @@ -216,7 +216,7 @@ int CTabbedWindow::Resizer(UTILRESIZECONTROL *urc) /////////////////////////////////////////////////////////////////////////////////////////
-CTabbedWindow* CTabbedWindow::AddPage(MCONTACT hContact, wchar_t *pwszText, int iNoActivate)
+CMsgDialog* CTabbedWindow::AddPage(MCONTACT hContact, wchar_t *pwszText, int iNoActivate)
{
CMsgDialog *pDlg = new CMsgDialog(this, hContact);
pDlg->m_wszInitialText = pwszText;
@@ -256,7 +256,7 @@ CTabbedWindow* CTabbedWindow::AddPage(MCONTACT hContact, wchar_t *pwszText, int }
PostMessage(m_hwnd, WM_SIZE, 0, 0);
- return this;
+ return pDlg;
}
void CTabbedWindow::AddPage(SESSION_INFO *si, int insertAt)
|