summaryrefslogtreecommitdiff
path: root/src/core/stdmsg
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-09-03 13:36:04 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-09-03 13:36:04 +0300
commitb8b9a01e61efee993410b2d16913b7218ec3a529 (patch)
tree22e9a677c7faed12447d5cc96777c19a9b63da14 /src/core/stdmsg
parentba09e75933056cd4638fe849419ead008e2ba5f0 (diff)
StdMsg:
- more slack removed from msgs.h - fix for window cascading
Diffstat (limited to 'src/core/stdmsg')
-rw-r--r--src/core/stdmsg/src/chat_window.cpp45
-rw-r--r--src/core/stdmsg/src/globals.cpp6
-rw-r--r--src/core/stdmsg/src/msgdialog.cpp200
-rw-r--r--src/core/stdmsg/src/msgs.cpp27
-rw-r--r--src/core/stdmsg/src/msgs.h21
-rw-r--r--src/core/stdmsg/src/stdafx.h1
-rw-r--r--src/core/stdmsg/src/tabs.cpp24
7 files changed, 140 insertions, 184 deletions
diff --git a/src/core/stdmsg/src/chat_window.cpp b/src/core/stdmsg/src/chat_window.cpp
index 75eac732e4..3f98522e12 100644
--- a/src/core/stdmsg/src/chat_window.cpp
+++ b/src/core/stdmsg/src/chat_window.cpp
@@ -29,14 +29,8 @@ static wchar_t szTrimString[] = L":;,.!?\'\"><()[]- \r\n";
/////////////////////////////////////////////////////////////////////////////////////////
CChatRoomDlg::CChatRoomDlg(CTabbedWindow *pOwner, SESSION_INFO *si) :
- CSuper(pOwner, IDD_CHANNEL, si),
- m_btnOk(this, IDOK),
-
- m_splitterX(this, IDC_SPLITTERX),
- m_splitterY(this, IDC_SPLITTERY)
+ CSuper(pOwner, IDD_CHANNEL, si)
{
- m_szProto = si->pszModule;
-
m_btnOk.OnClick = Callback(this, &CChatRoomDlg::onClick_Ok);
m_btnFilter.OnClick = Callback(this, &CChatRoomDlg::onClick_Filter);
@@ -1057,26 +1051,6 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, TRUE);
return TRUE;
}
- break;
-
- case TTN_NEEDTEXT:
- if (((LPNMHDR)lParam)->idFrom == (UINT_PTR)m_nickList.GetHwnd()) {
- LPNMTTDISPINFO lpttd = (LPNMTTDISPINFO)lParam;
- SESSION_INFO* parentdat = (SESSION_INFO*)GetWindowLongPtr(m_hwnd, GWLP_USERDATA);
- POINT p;
- GetCursorPos(&p);
- ScreenToClient(m_nickList.GetHwnd(), &p);
- int item = LOWORD(m_nickList.SendMsg(LB_ITEMFROMPOINT, 0, MAKELPARAM(p.x, p.y)));
- USERINFO *ui = g_chatApi.SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, item);
- if (ui != nullptr) {
- static wchar_t ptszBuf[1024];
- mir_snwprintf(ptszBuf, L"%s: %s\r\n%s: %s\r\n%s: %s",
- TranslateT("Nickname"), ui->pszNick,
- TranslateT("Unique ID"), ui->pszUID,
- TranslateT("Status"), g_chatApi.TM_WordToString(parentdat->pStatuses, ui->Status));
- lpttd->lpszText = ptszBuf;
- }
- }
}
break;
@@ -1097,23 +1071,6 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
UpdateTitle();
break;
- case DM_CLOSETAB:
- CloseTab();
- break;
-
- case DM_CASCADENEWWINDOW:
- if ((HWND)wParam != m_pOwner->GetHwnd()) {
- RECT rcThis, rcNew;
- GetWindowRect(m_pOwner->GetHwnd(), &rcThis);
- GetWindowRect((HWND)wParam, &rcNew);
- if (abs(rcThis.left - rcNew.left) < 3 && abs(rcThis.top - rcNew.top) < 3) {
- int offset = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYFRAME);
- SetWindowPos((HWND)wParam, nullptr, rcNew.left + offset, rcNew.top + offset, 0, 0, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE);
- *(int *)lParam = 1;
- }
- }
- break;
-
case WM_LBUTTONDBLCLK:
if (LOWORD(lParam) < 30)
ScrollToBottom();
diff --git a/src/core/stdmsg/src/globals.cpp b/src/core/stdmsg/src/globals.cpp
index d4561e6007..3d0cacca0c 100644
--- a/src/core/stdmsg/src/globals.cpp
+++ b/src/core/stdmsg/src/globals.cpp
@@ -53,9 +53,9 @@ static int OnShutdown(WPARAM, LPARAM)
static int OnMetaChanged(WPARAM hMeta, LPARAM)
{
if (hMeta) {
- HWND hwnd = Srmm_FindWindow(hMeta);
- if (hwnd != nullptr)
- SendMessage(hwnd, DM_GETAVATAR, 0, 0);
+ auto *pDlg = Srmm_FindDialog(hMeta);
+ if (pDlg != nullptr)
+ pDlg->UpdateAvatar();
}
return 0;
}
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp
index 1f5b7d25a6..52519ebf1d 100644
--- a/src/core/stdmsg/src/msgdialog.cpp
+++ b/src/core/stdmsg/src/msgdialog.cpp
@@ -33,23 +33,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define ENTERCLICKTIME 1000 //max time in ms during which a double-tap on enter will cause a send
-static int CompareDialogs(const CMsgDialog *p1, const CMsgDialog *p2)
-{
- if (p1->GetHwnd() == p2->GetHwnd())
- return 0;
-
- return (p1->GetHwnd() < p2->GetHwnd()) ? -1 : 1;
-}
-
-LIST<CMsgDialog> g_arDialogs(10, CompareDialogs);
+LIST<CMsgDialog> g_arDialogs(10, PtrKeySortT);
/////////////////////////////////////////////////////////////////////////////////////////
-static void AddToFileList(wchar_t ***pppFiles, int *totalCount, const wchar_t *szFilename)
+static void AddToFileList(wchar_t ***pppFiles, int &totalCount, const wchar_t *szFilename)
{
- *pppFiles = (wchar_t **)mir_realloc(*pppFiles, (++ * totalCount + 1) * sizeof(wchar_t *));
- (*pppFiles)[*totalCount] = nullptr;
- (*pppFiles)[*totalCount - 1] = mir_wstrdup(szFilename);
+ *pppFiles = (wchar_t **)mir_realloc(*pppFiles, (++totalCount + 1) * sizeof(wchar_t *));
+ (*pppFiles)[totalCount] = nullptr;
+ (*pppFiles)[totalCount - 1] = mir_wstrdup(szFilename);
if (GetFileAttributes(szFilename) & FILE_ATTRIBUTE_DIRECTORY) {
WIN32_FIND_DATA fd;
@@ -78,6 +70,8 @@ static void SetEditorText(HWND hwnd, const wchar_t *txt)
CMsgDialog::CMsgDialog(CTabbedWindow *pOwner, int iDialogId, SESSION_INFO *si) :
CSuper(g_plugin, iDialogId, si),
m_btnOk(this, IDOK),
+ m_splitterX(this, IDC_SPLITTERX),
+ m_splitterY(this, IDC_SPLITTERY),
m_pOwner(pOwner)
{
m_autoClose = 0;
@@ -86,9 +80,17 @@ CMsgDialog::CMsgDialog(CTabbedWindow *pOwner, int iDialogId, SESSION_INFO *si) :
g_arDialogs.insert(this);
}
+bool CMsgDialog::OnInitDialog()
+{
+ m_szProto = GetContactProto(m_hContact);
+
+ return CSuper::OnInitDialog();
+}
+
void CMsgDialog::OnDestroy()
{
- g_arDialogs.remove(this);
+ if (g_arDialogs.remove(this) == -1)
+ DebugBreak();
CSuper::OnDestroy();
}
@@ -164,6 +166,8 @@ LRESULT CMsgDialog::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam)
return CSuper::WndProc_Message(msg, wParam, lParam);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
int CMsgDialog::GetImageId() const
{
if (m_nFlash & 1)
@@ -215,7 +219,6 @@ void CMsgDialog::StopFlash()
CSrmmWindow::CSrmmWindow(CTabbedWindow *pOwner, MCONTACT hContact) :
CSuper(pOwner, IDD_MSG),
- m_splitter(this, IDC_SPLITTERY),
m_avatar(this, IDC_AVATAR),
m_cmdList(20),
m_bNoActivate(g_dat.bDoNotStealFocus)
@@ -223,7 +226,7 @@ CSrmmWindow::CSrmmWindow(CTabbedWindow *pOwner, MCONTACT hContact) :
m_hContact = hContact;
m_btnOk.OnClick = Callback(this, &CSrmmWindow::onClick_Ok);
- m_splitter.OnChange = Callback(this, &CSrmmWindow::OnSplitterMoved);
+ m_splitterY.OnChange = Callback(this, &CSrmmWindow::OnSplitterMoved);
}
bool CSrmmWindow::OnInitDialog()
@@ -243,8 +246,6 @@ bool CSrmmWindow::OnInitDialog()
mir_free(m_wszInitialText);
}
- m_szProto = GetContactProto(m_hContact);
-
// avatar stuff
m_limitAvatarH = g_dat.bLimitAvatarHeight ? g_dat.iAvatarHeight : 0;
@@ -259,7 +260,7 @@ bool CSrmmWindow::OnInitDialog()
GetWindowRect(m_message.GetHwnd(), &m_minEditInit);
m_iSplitterY = g_plugin.getDword(g_dat.bSavePerContact ? m_hContact : 0, "splitterPos", m_minEditInit.bottom - m_minEditInit.top);
- SendMessage(m_hwnd, DM_UPDATESIZEBAR, 0, 0);
+ UpdateSizeBar();
m_avatar.Enable(false);
@@ -378,7 +379,7 @@ bool CSrmmWindow::OnInitDialog()
SetFocus(m_message.GetHwnd());
}
- SendMessage(m_hwnd, DM_GETAVATAR, 0, 0);
+ UpdateAvatar();
NotifyEvent(MSG_WINDOW_EVT_OPEN);
return true;
}
@@ -502,7 +503,7 @@ void CSrmmWindow::OnOptionsApplied(bool bUpdateAvatar)
}
ShowWindow(GetDlgItem(m_hwnd, IDCANCEL), SW_HIDE);
- m_splitter.Show();
+ m_splitterY.Show();
m_btnOk.Show(g_dat.bSendButton);
m_btnOk.Enable(GetWindowTextLength(m_message.GetHwnd()) != 0);
@@ -529,7 +530,7 @@ void CSrmmWindow::OnOptionsApplied(bool bUpdateAvatar)
m_limitAvatarH = g_dat.bLimitAvatarHeight ? g_dat.iAvatarHeight : 0;
if (bUpdateAvatar)
- SendMessage(m_hwnd, DM_GETAVATAR, 0, 0);
+ UpdateAvatar();
InvalidateRect(m_message.GetHwnd(), nullptr, FALSE);
@@ -636,7 +637,7 @@ void CSrmmWindow::ProcessFileDrop(HDROP hDrop)
wchar_t **ppFiles = nullptr;
for (int i = 0; i < fileCount; i++) {
DragQueryFile(hDrop, i, szFilename, _countof(szFilename));
- AddToFileList(&ppFiles, &totalCount, szFilename);
+ AddToFileList(&ppFiles, totalCount, szFilename);
}
CallServiceSync(MS_FILE_SENDSPECIFICFILEST, m_hContact, (LPARAM)ppFiles);
if (ppFiles) {
@@ -658,8 +659,8 @@ void CSrmmWindow::ShowAvatar()
}
else m_avatarPic = nullptr;
- SendMessage(m_hwnd, DM_UPDATESIZEBAR, 0, 0);
- SendMessage(m_hwnd, DM_AVATARSIZECHANGE, 0, 0);
+ UpdateSizeBar();
+ Resize();
}
void CSrmmWindow::ShowTime(bool bForce)
@@ -713,6 +714,16 @@ void CSrmmWindow::SetStatusText(const wchar_t *wszText, HICON hIcon)
SendMessage(m_pOwner->m_hwndStatus, SB_SETTEXT, 0, (LPARAM)(wszText == nullptr ? L"" : wszText));
}
+void CSrmmWindow::UpdateAvatar()
+{
+ PROTO_AVATAR_INFORMATION ai = {};
+ ai.hContact = m_hContact;
+ CallProtoService(m_szProto, PS_GETAVATARINFO, GAIF_FORCE, (LPARAM)&ai);
+
+ ShowAvatar();
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, 1);
+}
+
void CSrmmWindow::UpdateIcon(WPARAM wParam)
{
if (!m_hContact || !m_szProto)
@@ -764,6 +775,39 @@ void CSrmmWindow::UpdateReadChars()
}
}
+void CSrmmWindow::UpdateSizeBar()
+{
+ m_minEditBoxSize.cx = m_minEditInit.right - m_minEditInit.left;
+ m_minEditBoxSize.cy = m_minEditInit.bottom - m_minEditInit.top;
+ if (g_dat.bShowAvatar) {
+ if (m_avatarPic == nullptr || !g_dat.bShowAvatar) {
+ m_avatarWidth = 50;
+ m_avatarHeight = 50;
+ m_avatar.Hide();
+ return;
+ }
+ else {
+ BITMAP bminfo;
+ GetObject(m_avatarPic, sizeof(bminfo), &bminfo);
+ m_avatarWidth = bminfo.bmWidth + 2;
+ m_avatarHeight = bminfo.bmHeight + 2;
+ if (m_limitAvatarH && m_avatarHeight > m_limitAvatarH) {
+ m_avatarWidth = bminfo.bmWidth * m_limitAvatarH / bminfo.bmHeight + 2;
+ m_avatarHeight = m_limitAvatarH + 2;
+ }
+ m_avatar.Show();
+ }
+
+ if (m_avatarPic && m_minEditBoxSize.cy <= m_avatarHeight) {
+ m_minEditBoxSize.cy = m_avatarHeight + 8;
+ if (m_iSplitterY < m_minEditBoxSize.cy) {
+ m_iSplitterY = m_minEditBoxSize.cy;
+ Resize();
+ }
+ }
+ }
+}
+
void CSrmmWindow::UpdateTitle()
{
wchar_t newtitle[256];
@@ -790,6 +834,11 @@ void CSrmmWindow::UpdateTitle()
}
}
+void CSrmmWindow::UserTyping(int nSecs)
+{
+ m_nTypeSecs = (nSecs > 0) ? nSecs : 0;
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
int CSrmmWindow::Resizer(UTILRESIZECONTROL *urc)
@@ -1102,75 +1151,6 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
ShowAvatar();
break;
- case DM_AVATARCALCSIZE:
- if (m_avatarPic == nullptr || !g_dat.bShowAvatar) {
- m_avatarWidth = 50;
- m_avatarHeight = 50;
- m_avatar.Hide();
- return 0;
- }
- else {
- BITMAP bminfo;
- GetObject(m_avatarPic, sizeof(bminfo), &bminfo);
- m_avatarWidth = bminfo.bmWidth + 2;
- m_avatarHeight = bminfo.bmHeight + 2;
- if (m_limitAvatarH && m_avatarHeight > m_limitAvatarH) {
- m_avatarWidth = bminfo.bmWidth * m_limitAvatarH / bminfo.bmHeight + 2;
- m_avatarHeight = m_limitAvatarH + 2;
- }
- m_avatar.Show();
- }
- break;
-
- case DM_UPDATESIZEBAR:
- m_minEditBoxSize.cx = m_minEditInit.right - m_minEditInit.left;
- m_minEditBoxSize.cy = m_minEditInit.bottom - m_minEditInit.top;
- if (g_dat.bShowAvatar) {
- SendMessage(m_hwnd, DM_AVATARCALCSIZE, 0, 0);
- if (m_avatarPic && m_minEditBoxSize.cy <= m_avatarHeight) {
- m_minEditBoxSize.cy = m_avatarHeight + 8;
- if (m_iSplitterY < m_minEditBoxSize.cy) {
- m_iSplitterY = m_minEditBoxSize.cy;
- Resize();
- }
- }
- }
- break;
-
- case DM_AVATARSIZECHANGE:
- GetWindowRect(m_message.GetHwnd(), &rc);
- Resize();
- break;
-
- case DM_GETAVATAR:
- {
- PROTO_AVATAR_INFORMATION ai = {};
- ai.hContact = m_hContact;
- CallProtoService(m_szProto, PS_GETAVATARINFO, GAIF_FORCE, (LPARAM)&ai);
-
- ShowAvatar();
- SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, 1);
- }
- break;
-
- case DM_TYPING:
- m_nTypeSecs = (INT_PTR)lParam > 0 ? (int)lParam : 0;
- break;
-
- case DM_USERNAMETOCLIP:
- if (m_hContact) {
- ptrW id(Contact_GetInfo(CNF_UNIQUEID, m_hContact, m_szProto));
- if (id != nullptr && OpenClipboard(m_hwnd)) {
- EmptyClipboard();
- HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE, mir_wstrlen(id) * sizeof(wchar_t) + 1);
- mir_wstrcpy((wchar_t*)GlobalLock(hData), id);
- GlobalUnlock(hData);
- SetClipboardData(CF_UNICODETEXT, hData);
- CloseClipboard();
- }
- }
- break;
-
case DM_OPTIONSAPPLIED:
OnOptionsApplied(wParam != 0);
break;
@@ -1181,19 +1161,6 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
Resize();
break;
- case DM_CASCADENEWWINDOW:
- if ((HWND)wParam != m_hwnd) {
- RECT rcThis, rcNew;
- GetWindowRect(m_pOwner->GetHwnd(), &rcThis);
- GetWindowRect((HWND)wParam, &rcNew);
- if (abs(rcThis.left - rcNew.left) < 3 && abs(rcThis.top - rcNew.top) < 3) {
- int offset = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYFRAME);
- SetWindowPos((HWND)wParam, nullptr, rcNew.left + offset, rcNew.top + offset, 0, 0, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE);
- *(int *)lParam = 1;
- }
- }
- break;
-
case WM_CBD_LOADICONS:
Srmm_UpdateToolbarIcons(m_hwnd);
break;
@@ -1363,8 +1330,19 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_USERMENU:
- if (GetKeyState(VK_SHIFT) & 0x8000) // copy user name
- SendMessage(m_hwnd, DM_USERNAMETOCLIP, 0, 0);
+ if (GetKeyState(VK_SHIFT) & 0x8000) { // copy user name
+ ptrW id(Contact_GetInfo(CNF_UNIQUEID, m_hContact, m_szProto));
+ if (id != nullptr && OpenClipboard(m_hwnd)) {
+ HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE, mir_wstrlen(id) * sizeof(wchar_t) + 1);
+ if (hData) {
+ EmptyClipboard();
+ mir_wstrcpy((wchar_t*)GlobalLock(hData), id);
+ GlobalUnlock(hData);
+ SetClipboardData(CF_UNICODETEXT, hData);
+ CloseClipboard();
+ }
+ }
+ }
else {
HMENU hMenu = Menu_BuildContactMenu(m_hContact);
GetWindowRect(GetDlgItem(m_hwnd, LOWORD(wParam)), &rc);
@@ -1486,10 +1464,6 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
UpdateTitle();
break;
- case DM_CLOSETAB:
- CloseTab();
- break;
-
case DM_STATUSICONCHANGE:
SendMessage(m_pOwner->m_hwndStatus, SB_SETTEXT, (SBT_OWNERDRAW | (SendMessage(m_pOwner->m_hwndStatus, SB_GETPARTS, 0, 0) - 1)), 0);
break;
diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp
index c6995229d5..71b7b90e38 100644
--- a/src/core/stdmsg/src/msgs.cpp
+++ b/src/core/stdmsg/src/msgs.cpp
@@ -29,6 +29,14 @@ int OnCheckPlugins(WPARAM, LPARAM);
/////////////////////////////////////////////////////////////////////////////////////////
+CMsgDialog* Srmm_FindDialog(MCONTACT hContact)
+{
+ HWND hwnd = Srmm_FindWindow(hContact);
+ return (hwnd) ? (CMsgDialog *)GetWindowLongPtr(hwnd, GWLP_USERDATA) : nullptr;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
int SendMessageDirect(const wchar_t *szMsg, MCONTACT hContact)
{
if (hContact == 0)
@@ -175,9 +183,9 @@ static int TypingMessage(WPARAM hContact, LPARAM lParam)
Skin_PlaySound((lParam) ? "TNStart" : "TNStop");
- HWND hwnd = Srmm_FindWindow(hContact);
- if (hwnd)
- SendMessage(hwnd, DM_TYPING, 0, lParam);
+ auto *pDlg = Srmm_FindDialog(hContact);
+ if (pDlg)
+ pDlg->UserTyping(lParam);
else if (lParam && g_dat.bShowTypingTray) {
wchar_t szTip[256];
mir_snwprintf(szTip, TranslateT("%s is typing a message"), Clist_GetContactDisplayName(hContact));
@@ -224,9 +232,9 @@ static int MessageSettingChanged(WPARAM hContact, LPARAM lParam)
// If a contact gets deleted, close its message window if there is any
static int ContactDeleted(WPARAM wParam, LPARAM)
{
- HWND hwnd = Srmm_FindWindow(wParam);
- if (hwnd)
- SendMessage(hwnd, DM_CLOSETAB, 0, 0);
+ auto *pDlg = Srmm_FindDialog(wParam);
+ if (pDlg)
+ pDlg->CloseTab();
return 0;
}
@@ -459,9 +467,10 @@ static int SplitmsgModulesLoaded(WPARAM, LPARAM)
return 0;
}
-int PreshutdownSendRecv(WPARAM, LPARAM)
+static int Preshutdown(WPARAM, LPARAM)
{
- Srmm_Broadcast(DM_CLOSETAB, 0, 0);
+ for (auto &it : g_arDialogs.rev_iter())
+ it->CloseTab();
return 0;
}
@@ -515,7 +524,7 @@ int LoadSendRecvMessageModule(void)
HookEvent(ME_PROTO_CONTACTISTYPING, TypingMessage);
HookEvent(ME_SKIN_ICONSCHANGED, IconsChanged);
HookEvent(ME_SYSTEM_MODULESLOADED, SplitmsgModulesLoaded);
- HookEvent(ME_SYSTEM_PRESHUTDOWN, PreshutdownSendRecv);
+ HookEvent(ME_SYSTEM_PRESHUTDOWN, Preshutdown);
CreateServiceFunction(MS_MSG_SENDMESSAGE, SendMessageCommand);
CreateServiceFunction(MS_MSG_SENDMESSAGEW, SendMessageCommand_W);
diff --git a/src/core/stdmsg/src/msgs.h b/src/core/stdmsg/src/msgs.h
index cc7b57a17f..c96dffe46b 100644
--- a/src/core/stdmsg/src/msgs.h
+++ b/src/core/stdmsg/src/msgs.h
@@ -23,18 +23,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define SRMM_MSGS_H
#define HM_DBEVENTADDED (WM_USER+12)
-#define DM_CASCADENEWWINDOW (WM_USER+13)
#define DM_OPTIONSAPPLIED (WM_USER+14)
-#define DM_CLOSETAB (WM_USER+15)
#define DM_UPDATETITLE (WM_USER+16)
#define DM_NEWTIMEZONE (WM_USER+18)
-#define DM_TYPING (WM_USER+20)
-#define DM_UPDATEWINICON (WM_USER+21)
-#define DM_USERNAMETOCLIP (WM_USER+23)
-#define DM_AVATARSIZECHANGE (WM_USER+24)
-#define DM_AVATARCALCSIZE (WM_USER+25)
-#define DM_GETAVATAR (WM_USER+26)
-#define DM_UPDATESIZEBAR (WM_USER+27)
#define HM_AVATARACK (WM_USER+28)
#define DM_STATUSICONCHANGE (WM_USER+31)
@@ -48,6 +39,8 @@ class CMsgDialog : public CSrmmBaseDialog
protected:
CCtrlButton m_btnOk;
+ CSplitter m_splitterX, m_splitterY;
+
CTabbedWindow *m_pOwner;
DWORD m_nFlash = 0;
char *m_szProto = nullptr;
@@ -58,6 +51,7 @@ protected:
virtual void OnActivate() PURE;
+ bool OnInitDialog() override;
void OnDestroy() override;
INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
@@ -65,6 +59,8 @@ protected:
public:
virtual void RemakeLog() {}
+ virtual void UpdateAvatar() {}
+ virtual void UserTyping(int) {}
int GetImageId() const;
@@ -88,7 +84,6 @@ class CSrmmWindow : public CMsgDialog
LRESULT WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) override;
CCtrlBase m_avatar;
- CSplitter m_splitter;
void NotifyTyping(int mode);
void ProcessFileDrop(HDROP hDrop);
@@ -98,6 +93,7 @@ class CSrmmWindow : public CMsgDialog
void StreamInEvents(MEVENT hDbEventFirst, int count, bool bAppend);
void UpdateIcon(WPARAM wParam);
void UpdateLastMessage(void);
+ void UpdateSizeBar(void);
HICON m_hStatusIcon = nullptr;
HFONT m_hFont = nullptr;
@@ -144,7 +140,9 @@ public:
void LoadSettings() override {}
void RemakeLog() override;
void SetStatusText(const wchar_t*, HICON) override;
+ void UpdateAvatar() override;
void UpdateTitle() override;
+ void UserTyping(int nSecs) override;
void OnSplitterMoved(CSplitter*);
@@ -176,9 +174,6 @@ class CChatRoomDlg : public CMsgDialog
wchar_t szTabSave[20];
- CCtrlButton m_btnOk;
- CSplitter m_splitterX, m_splitterY;
-
int m_iSplitterX, m_iSplitterY;
public:
diff --git a/src/core/stdmsg/src/stdafx.h b/src/core/stdmsg/src/stdafx.h
index 918f63a017..2426997b54 100644
--- a/src/core/stdmsg/src/stdafx.h
+++ b/src/core/stdmsg/src/stdafx.h
@@ -180,6 +180,7 @@ SESSION_INFO* SM_GetNextWindow(SESSION_INFO *si);
void AddIcons(void);
// tools.cpp
+CMsgDialog* Srmm_FindDialog(MCONTACT hContact);
void SetButtonsPos(HWND hwndDlg, bool bIsChat);
#pragma comment(lib,"comctl32.lib")
diff --git a/src/core/stdmsg/src/tabs.cpp b/src/core/stdmsg/src/tabs.cpp
index 0494c08cc4..15c3d47d9f 100644
--- a/src/core/stdmsg/src/tabs.cpp
+++ b/src/core/stdmsg/src/tabs.cpp
@@ -399,8 +399,28 @@ void CTabbedWindow::SetWindowPosition()
else SetWindowPos(m_hwnd, nullptr, 0, 0, 550, 400, SWP_NOZORDER | SWP_NOMOVE | SWP_SHOWWINDOW);
}
- if (!g_dat.bSavePerContact && g_dat.bCascade)
- Srmm_Broadcast(DM_CASCADENEWWINDOW, (WPARAM)m_hwnd, (LPARAM)&m_windowWasCascaded);
+ if (!g_dat.bSavePerContact && g_dat.bCascade) {
+ RECT rc, rcMax = {};
+ CTabbedWindow *pMaxTab = nullptr;
+
+ for (auto &it : g_arDialogs) {
+ auto *pTab = it->m_pOwner;
+ if (pTab == this)
+ continue;
+
+ GetWindowRect(pTab->GetHwnd(), &rc);
+ if (rc.left > rcMax.left && rc.top > rcMax.top) {
+ pMaxTab = pTab;
+ rcMax = rc;
+ }
+ }
+
+ if (pMaxTab) {
+ m_windowWasCascaded = 1;
+ int offset = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYFRAME);
+ SetWindowPos(m_hwnd, nullptr, rcMax.left + offset, rcMax.top + offset, 0, 0, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE);
+ }
+ }
}
void CTabbedWindow::SwitchNextTab()