summaryrefslogtreecommitdiff
path: root/plugins/Scriver/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-09-09 15:08:43 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-09-09 15:08:43 +0300
commit36c6cafcd006dc8d07d67d127bf4d26b7940b1b4 (patch)
treeb260809733ea1aed8aeee368993ca5021b5ce84b /plugins/Scriver/src
parent33d16d137f4e468996592d3961a4cf8a2849cf55 (diff)
Scriver: container-related code moved to the class
Diffstat (limited to 'plugins/Scriver/src')
-rw-r--r--plugins/Scriver/src/chat_main.cpp16
-rw-r--r--plugins/Scriver/src/chat_window.cpp5
-rw-r--r--plugins/Scriver/src/input.cpp22
-rw-r--r--plugins/Scriver/src/msgdialog.cpp51
-rw-r--r--plugins/Scriver/src/msgs.cpp20
-rw-r--r--plugins/Scriver/src/msgs.h52
-rw-r--r--plugins/Scriver/src/stdafx.h2
-rw-r--r--plugins/Scriver/src/tabs.cpp579
-rw-r--r--plugins/Scriver/src/tabs.h95
9 files changed, 407 insertions, 435 deletions
diff --git a/plugins/Scriver/src/chat_main.cpp b/plugins/Scriver/src/chat_main.cpp
index 6fdf6ac8bc..ddf786e469 100644
--- a/plugins/Scriver/src/chat_main.cpp
+++ b/plugins/Scriver/src/chat_main.cpp
@@ -44,16 +44,12 @@ static void OnFlashHighlight(SESSION_INFO *si, int bInactive)
if (!bInactive || !si->pDlg)
return;
- if (g_Settings.bFlashWindowHighlight)
- SendMessage(GetParent(si->pDlg->GetHwnd()), CM_STARTFLASHING, 0, 0);
-
si->wState |= GC_EVENT_HIGHLIGHT;
si->pDlg->FixTabIcons();
si->pDlg->UpdateTitle();
- HWND hwndParent = GetParent(si->pDlg->GetHwnd());
- if (g_Settings.bFlashWindowHighlight && GetActiveWindow() != si->pDlg->GetHwnd() && GetForegroundWindow() != hwndParent)
- SendMessage(hwndParent, CM_STARTFLASHING, 0, 0);
+ if (g_Settings.bFlashWindowHighlight)
+ si->pDlg->StartFlashing();
}
static void OnFlashWindow(SESSION_INFO *si, int bInactive)
@@ -61,15 +57,11 @@ static void OnFlashWindow(SESSION_INFO *si, int bInactive)
if (!bInactive || !si->pDlg)
return;
- if (g_Settings.bFlashWindow)
- SendMessage(GetParent(si->pDlg->GetHwnd()), CM_STARTFLASHING, 0, 0);
-
si->pDlg->FixTabIcons();
si->pDlg->UpdateTitle();
- HWND hwndParent = GetParent(si->pDlg->GetHwnd());
- if (g_Settings.bFlashWindow && GetActiveWindow() != hwndParent && GetForegroundWindow() != hwndParent)
- SendMessage(hwndParent, CM_STARTFLASHING, 0, 0);
+ if (g_Settings.bFlashWindow)
+ si->pDlg->StartFlashing();
}
static void OnDestroyModule(MODULEINFO *mi)
diff --git a/plugins/Scriver/src/chat_window.cpp b/plugins/Scriver/src/chat_window.cpp
index b3ff9bea07..ea8deba198 100644
--- a/plugins/Scriver/src/chat_window.cpp
+++ b/plugins/Scriver/src/chat_window.cpp
@@ -125,7 +125,7 @@ void CMsgDialog::FixTabIcons()
TabControlData tcd = {};
tcd.iFlags = TCDF_ICON;
tcd.hIcon = hIcon;
- SendMessage(m_hwndParent, CM_UPDATETABCONTROL, (WPARAM)&tcd, (LPARAM)m_hwnd);
+ m_pParent->UpdateTabControl(tcd, m_hwnd);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -331,8 +331,7 @@ void ShowRoom(SESSION_INFO *si)
else pDlg = si->pDlg;
SendMessage(pDlg->GetHwnd(), DM_UPDATETABCONTROL, -1, (LPARAM)si);
- SendMessage(GetParent(pDlg->GetHwnd()), CM_ACTIVATECHILD, 0, (LPARAM)pDlg->GetHwnd());
- SendMessage(GetParent(pDlg->GetHwnd()), CM_POPUPWINDOW, 0, (LPARAM)pDlg->GetHwnd());
+ pDlg->PopupWindow();
SendMessage(pDlg->GetHwnd(), WM_MOUSEACTIVATE, 0, 0);
SetFocus(GetDlgItem(pDlg->GetHwnd(), IDC_SRMM_MESSAGE));
}
diff --git a/plugins/Scriver/src/input.cpp b/plugins/Scriver/src/input.cpp
index 825a97ce55..11f89db265 100644
--- a/plugins/Scriver/src/input.cpp
+++ b/plugins/Scriver/src/input.cpp
@@ -155,25 +155,25 @@ int CMsgDialog::InputAreaShortcuts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
switch (action) {
case KB_PREV_TAB:
- SendMessage(m_pParent->hwnd, CM_ACTIVATEPREV, 0, (LPARAM)m_hwnd);
+ m_pParent->ActivatePrevChild(m_hwnd);
return FALSE;
case KB_NEXT_TAB:
- SendMessage(m_pParent->hwnd, CM_ACTIVATENEXT, 0, (LPARAM)m_hwnd);
+ m_pParent->ActivateNextChild(m_hwnd);
return FALSE;
case KB_SWITCHSTATUSBAR:
- SendMessage(m_pParent->hwnd, DM_SWITCHSTATUSBAR, 0, 0);
+ SendMessage(m_pParent->m_hwnd, DM_SWITCHSTATUSBAR, 0, 0);
return FALSE;
case KB_SWITCHTITLEBAR:
- SendMessage(m_pParent->hwnd, DM_SWITCHTITLEBAR, 0, 0);
+ SendMessage(m_pParent->m_hwnd, DM_SWITCHTITLEBAR, 0, 0);
return FALSE;
case KB_SWITCHINFOBAR:
- SendMessage(m_pParent->hwnd, DM_SWITCHINFOBAR, 0, 0);
+ SendMessage(m_pParent->m_hwnd, DM_SWITCHINFOBAR, 0, 0);
return FALSE;
case KB_SWITCHTOOLBAR:
- SendMessage(m_pParent->hwnd, DM_SWITCHTOOLBAR, 0, 0);
+ SendMessage(m_pParent->m_hwnd, DM_SWITCHTOOLBAR, 0, 0);
return FALSE;
case KB_MINIMIZE:
- ShowWindow(m_pParent->hwnd, SW_MINIMIZE);
+ ShowWindow(m_pParent->m_hwnd, SW_MINIMIZE);
return FALSE;
case KB_CLOSE:
SendMessage(m_hwnd, WM_CLOSE, 0, 0);
@@ -190,7 +190,7 @@ int CMsgDialog::InputAreaShortcuts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
case KB_TAB7:
case KB_TAB8:
case KB_TAB9:
- SendMessage(m_pParent->hwnd, CM_ACTIVATEBYINDEX, 0, action - KB_TAB1);
+ m_pParent->ActivateChildByIndex(action - KB_TAB1);
return FALSE;
case KB_SEND_ALL:
PostMessage(m_hwnd, WM_COMMAND, IDC_SENDALL, 0);
@@ -209,7 +209,7 @@ int CMsgDialog::InputAreaShortcuts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
switch (msg) {
case WM_KEYDOWN:
if (wParam >= '1' && wParam <= '9' && isCtrl) {
- SendMessage(m_pParent->hwnd, CM_ACTIVATEBYINDEX, 0, wParam - '1');
+ m_pParent->ActivateChildByIndex(wParam - '1');
return 0;
}
@@ -270,11 +270,11 @@ int CMsgDialog::InputAreaShortcuts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
case WM_SYSKEYDOWN:
if ((wParam == VK_LEFT) && isAlt) {
- SendMessage(m_pParent->hwnd, CM_ACTIVATEPREV, 0, (LPARAM)m_hwnd);
+ m_pParent->ActivatePrevChild(m_hwnd);
return 0;
}
if ((wParam == VK_RIGHT) && isAlt) {
- SendMessage(m_pParent->hwnd, CM_ACTIVATENEXT, 0, (LPARAM)m_hwnd);
+ m_pParent->ActivateNextChild(m_hwnd);
return 0;
}
break;
diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp
index 699f8d4436..01159450a0 100644
--- a/plugins/Scriver/src/msgdialog.cpp
+++ b/plugins/Scriver/src/msgdialog.cpp
@@ -319,6 +319,8 @@ bool CMsgDialog::OnInitDialog()
m_bUseIEView = false;
}
+ m_pParent->AddChild(this);
+
if (isChat()) {
UpdateOptions();
UpdateStatusBar();
@@ -398,16 +400,15 @@ bool CMsgDialog::OnInitDialog()
} while ((hdbEvent = db_event_prev(m_hContact, hdbEvent)));
}
- SendMessage(m_hwndParent, CM_POPUPWINDOW, m_bIncoming, (LPARAM)m_hwnd);
SendMessage(m_hwnd, DM_OPTIONSAPPLIED, 0, 0);
if (notifyUnread) {
- if (GetForegroundWindow() != m_hwndParent || m_pParent->hwndActive != m_hwnd) {
+ if (GetForegroundWindow() != m_hwndParent || m_pParent->m_hwndActive != m_hwnd) {
m_iShowUnread = 1;
SendMessage(m_hwnd, DM_UPDATEICON, 0, 0);
SetTimer(m_hwnd, TIMERID_UNREAD, TIMEOUT_UNREAD, nullptr);
}
- SendMessage(m_hwndParent, CM_STARTFLASHING, 0, 0);
+ StartFlashing();
}
m_iMessagesInProgress = ReattachSendQueueItems(m_hwnd, m_hContact);
@@ -415,8 +416,7 @@ bool CMsgDialog::OnInitDialog()
SendMessage(m_hwnd, DM_SHOWMESSAGESENDING, 0, 0);
}
- SendMessage(m_hwndParent, CM_ADDCHILD, (WPARAM)this, 0);
-
+ PopupWindow(m_bIncoming);
NotifyEvent(MSG_WINDOW_EVT_OPEN);
return true;
}
@@ -466,7 +466,7 @@ void CMsgDialog::OnDestroy()
if (m_si)
m_si->pDlg = nullptr;
- SendMessage(m_hwndParent, CM_REMOVECHILD, 0, (LPARAM)m_hwnd);
+ m_pParent->RemoveChild(m_hwnd);
if (m_hwndIeview != nullptr) {
IEVIEWWINDOW ieWindow = { sizeof(ieWindow) };
ieWindow.iType = IEW_DESTROY;
@@ -791,7 +791,7 @@ void CMsgDialog::Reattach(HWND hwndContainer)
hParent = GetParent(hParent);
hParent = WindowList_Find(g_dat.hParentWindowList, (UINT_PTR)hParent);
- if ((hParent != nullptr && hParent != hwndContainer) || (hParent == nullptr && m_pParent->childrenCount > 1 && (GetKeyState(VK_CONTROL) & 0x8000))) {
+ if ((hParent != nullptr && hParent != hwndContainer) || (hParent == nullptr && m_pParent->m_iChildrenCount > 1 && (GetKeyState(VK_CONTROL) & 0x8000))) {
if (hParent == nullptr) {
hParent = GetParentWindow(hContact, false);
@@ -818,11 +818,11 @@ void CMsgDialog::Reattach(HWND hwndContainer)
NotifyEvent(MSG_WINDOW_EVT_CLOSING);
NotifyEvent(MSG_WINDOW_EVT_CLOSE);
SetParent(hParent);
- SendMessage(hwndContainer, CM_REMOVECHILD, 0, (LPARAM)m_hwnd);
+ m_pParent->RemoveChild(m_hwnd);
SendMessage(m_hwnd, DM_SETPARENT, 0, (LPARAM)hParent);
- SendMessage(hParent, CM_ADDCHILD, (WPARAM)this, 0);
+ m_pParent->AddChild(this);
SendMessage(m_hwnd, DM_UPDATETABCONTROL, 0, 0);
- SendMessage(hParent, CM_ACTIVATECHILD, 0, (LPARAM)m_hwnd);
+ m_pParent->ActivateChild(m_hwnd);
NotifyEvent(MSG_WINDOW_EVT_OPENING);
NotifyEvent(MSG_WINDOW_EVT_OPEN);
ShowWindow(hParent, SW_SHOWNA);
@@ -911,7 +911,7 @@ void CMsgDialog::ShowAvatar()
void CMsgDialog::UpdateStatusBar()
{
- if (m_pParent->hwndActive != m_hwnd)
+ if (m_pParent->m_hwndActive != m_hwnd)
return;
if (isChat()) {
@@ -923,12 +923,12 @@ void CMsgDialog::UpdateStatusBar()
sbd.iFlags = SBDF_TEXT | SBDF_ICON;
sbd.hIcon = m_si->wStatus == ID_STATUS_ONLINE ? m_si->pMI->hOnlineIcon : m_si->pMI->hOfflineIcon;
sbd.pszText = szTemp;
- SendMessage(m_hwndParent, CM_UPDATESTATUSBAR, (WPARAM)& sbd, (LPARAM)m_hwnd);
+ m_pParent->UpdateStatusBar(sbd, m_hwnd);
sbd.iItem = 1;
sbd.hIcon = nullptr;
sbd.pszText = L"";
- SendMessage(m_hwndParent, CM_UPDATESTATUSBAR, (WPARAM)& sbd, (LPARAM)m_hwnd);
+ m_pParent->UpdateStatusBar(sbd, m_hwnd);
Srmm_SetIconFlags(m_hContact, SRMM_MODULE, 0, 0);
}
@@ -955,8 +955,8 @@ void CMsgDialog::UpdateStatusBar()
sbd.pszText = szText;
}
else sbd.pszText = L"";
+ m_pParent->UpdateStatusBar(sbd, m_hwnd);
- SendMessage(m_hwndParent, CM_UPDATESTATUSBAR, (WPARAM)&sbd, (LPARAM)m_hwnd);
UpdateReadChars();
Srmm_SetIconFlags(m_hContact, SRMM_MODULE, 0, MBF_DISABLED);
@@ -971,7 +971,7 @@ void CMsgDialog::UpdateStatusBar()
void CMsgDialog::UpdateReadChars()
{
- if (m_pParent->hwndActive == m_hwnd) {
+ if (m_pParent->m_hwndActive == m_hwnd) {
wchar_t szText[256];
int len = m_message.GetRichTextLength(1200);
@@ -981,7 +981,7 @@ void CMsgDialog::UpdateReadChars()
sbd.hIcon = nullptr;
sbd.pszText = szText;
mir_snwprintf(szText, L"%d", len);
- SendMessage(m_hwndParent, CM_UPDATESTATUSBAR, (WPARAM)&sbd, (LPARAM)m_hwnd);
+ m_pParent->UpdateStatusBar(sbd, m_hwnd);
}
}
@@ -1042,7 +1042,7 @@ void CMsgDialog::UpdateTitle()
}
tbd.pszText = wszTitle.GetBuffer();
- SendMessage(m_hwndParent, CM_UPDATETITLEBAR, (WPARAM)&tbd, (LPARAM)m_hwnd);
+ m_pParent->UpdateTitleBar(tbd, m_hwnd);
if (isChat())
SendMessage(m_hwnd, DM_UPDATETABCONTROL, 0, 0);
@@ -1568,12 +1568,13 @@ INT_PTR CMsgDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
TitleBarData tbd = { 0 };
tbd.iFlags = TBDF_ICON;
GetTitlebarIcon(&tbd);
- SendMessage(m_hwndParent, CM_UPDATETITLEBAR, (WPARAM)&tbd, (LPARAM)m_hwnd);
+ m_pParent->UpdateTitleBar(tbd, m_hwnd);
TabControlData tcd;
tcd.iFlags = TCDF_ICON;
tcd.hIcon = GetTabIcon();
- SendMessage(m_hwndParent, CM_UPDATETABCONTROL, (WPARAM)&tcd, (LPARAM)m_hwnd);
+ m_pParent->UpdateTabControl(tcd, m_hwnd);
+
SendDlgItemMessage(m_hwnd, IDC_USERMENU, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_hStatusIcon);
}
break;
@@ -1583,7 +1584,7 @@ INT_PTR CMsgDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
tcd.iFlags = TCDF_TEXT | TCDF_ICON;
tcd.hIcon = GetTabIcon();
tcd.pszText = Clist_GetContactDisplayName(m_hContact);
- SendMessage(m_hwndParent, CM_UPDATETABCONTROL, (WPARAM)&tcd, (LPARAM)m_hwnd);
+ m_pParent->UpdateTabControl(tcd, m_hwnd);
break;
case DM_CLISTSETTINGSCHANGED:
@@ -1815,7 +1816,7 @@ INT_PTR CMsgDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
break;
case WM_SETFOCUS:
- SendMessage(m_hwndParent, CM_ACTIVATECHILD, 0, (LPARAM)m_hwnd);
+ m_pParent->ActivateChild(m_hwnd);
g_dat.hFocusWnd = m_hwnd;
PostMessage(m_hwnd, DM_SETFOCUS, 0, 0);
return TRUE;
@@ -1865,9 +1866,9 @@ INT_PTR CMsgDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
else
Skin_PlaySound("RecvMsgInactive");
if (g_dat.flags2.bSwitchToActive && (IsIconic(m_hwndParent) || GetActiveWindow() != m_hwndParent) && IsWindowVisible(m_hwndParent))
- SendMessage(m_hwndParent, CM_ACTIVATECHILD, 0, (LPARAM)m_hwnd);
+ m_pParent->ActivateChild(m_hwnd);
if (IsAutoPopup(m_hContact))
- SendMessage(m_hwndParent, CM_POPUPWINDOW, 1, (LPARAM)m_hwnd);
+ PopupWindow(true);
}
if (hDbEvent != m_hDbEventFirst && db_event_next(m_hContact, hDbEvent) == 0)
@@ -1881,7 +1882,7 @@ INT_PTR CMsgDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
SendMessage(m_hwnd, DM_UPDATEICON, 0, 0);
SetTimer(m_hwnd, TIMERID_UNREAD, TIMEOUT_UNREAD, nullptr);
}
- SendMessage(m_hwndParent, CM_STARTFLASHING, 0, 0);
+ StartFlashing();
}
}
}
@@ -1932,7 +1933,7 @@ INT_PTR CMsgDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
if (!m_bShowTyping) {
m_iShowUnread++;
tcd.hIcon = (m_iShowUnread & 1) ? m_hStatusIconOverlay : m_hStatusIcon;
- SendMessage(m_hwndParent, CM_UPDATETABCONTROL, (WPARAM)&tcd, (LPARAM)m_hwnd);
+ m_pParent->UpdateTabControl(tcd, m_hwnd);
}
}
break;
diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp
index 03cfe6049e..b0d45b1330 100644
--- a/plugins/Scriver/src/msgs.cpp
+++ b/plugins/Scriver/src/msgs.cpp
@@ -71,11 +71,11 @@ static INT_PTR ReadMessageCommand(WPARAM, LPARAM lParam)
CLISTEVENT *pcle = (CLISTEVENT*)lParam;
MCONTACT hContact = db_mc_tryMeta(pcle->hContact);
- HWND hwndExisting = Srmm_FindWindow(hContact);
- if (hwndExisting == nullptr)
+ auto *pDlg = Srmm_FindDialog(hContact);
+ if (pDlg == nullptr)
(new CMsgDialog(hContact, false))->Show();
else
- SendMessage(GetParent(hwndExisting), CM_POPUPWINDOW, 0, (LPARAM)hwndExisting);
+ pDlg->PopupWindow();
return 0;
}
@@ -139,18 +139,18 @@ static INT_PTR SendMessageCommandWorker(MCONTACT hContact, wchar_t *pszMsg)
if (!(CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND))
return 1;
- HWND hwnd = Srmm_FindWindow(hContact);
- if (hwnd != nullptr) {
+ auto *pDlg = Srmm_FindDialog(hContact);
+ if (pDlg != nullptr) {
if (pszMsg) {
- HWND hEdit = GetDlgItem(hwnd, IDC_SRMM_MESSAGE);
+ HWND hEdit = GetDlgItem(pDlg->GetHwnd(), IDC_SRMM_MESSAGE);
SendMessage(hEdit, EM_SETSEL, -1, GetWindowTextLength(hEdit));
SendMessage(hEdit, EM_REPLACESEL, FALSE, (LPARAM)pszMsg);
mir_free(pszMsg);
}
- SendMessage(GetParent(hwnd), CM_POPUPWINDOW, 0, (LPARAM)hwnd);
+ pDlg->PopupWindow();
}
else {
- CMsgDialog *pDlg = new CMsgDialog(hContact, false);
+ pDlg = new CMsgDialog(hContact, false);
pDlg->m_wszInitialText = pszMsg;
pDlg->Show();
}
@@ -285,8 +285,8 @@ void CMsgDialog::SetStatusText(const wchar_t *wszText, HICON hIcon)
{
ParentWindowData *pDat = m_pParent;
if (pDat != nullptr) {
- SendMessage(pDat->hwndStatus, SB_SETICON, 0, (LPARAM)hIcon);
- SendMessage(pDat->hwndStatus, SB_SETTEXT, 0, (LPARAM)(wszText == nullptr ? L"" : wszText));
+ SendMessage(pDat->m_hwndStatus, SB_SETICON, 0, (LPARAM)hIcon);
+ SendMessage(pDat->m_hwndStatus, SB_SETTEXT, 0, (LPARAM)(wszText == nullptr ? L"" : wszText));
}
}
diff --git a/plugins/Scriver/src/msgs.h b/plugins/Scriver/src/msgs.h
index 2c4cf6060d..c0411a893c 100644
--- a/plugins/Scriver/src/msgs.h
+++ b/plugins/Scriver/src/msgs.h
@@ -54,45 +54,6 @@ struct ToolbarButton
int width;
};
-struct TabCtrlData
-{
- int lastClickTime;
- WPARAM clickWParam;
- LPARAM clickLParam;
- POINT mouseLBDownPos;
- HIMAGELIST hDragImageList;
- int bDragging;
- int bDragged;
- int destTab;
- int srcTab;
-};
-
-struct ParentWindowData
-{
- HWND hwnd;
- MCONTACT hContact;
- int childrenCount;
- HWND hwndActive;
- HWND hwndStatus;
- HWND hwndTabs;
- TabFlags flags2;
- RECT childRect;
- POINT mouseLBDownPos;
- int mouseLBDown;
- int nFlash;
- int nFlashMax;
- int bMinimized;
- int bVMaximized;
- int iSplitterX, iSplitterY;
-
- bool bTopmost;
-
- int windowWasCascaded;
- TabCtrlData *tabCtrlDat;
- BOOL isChat;
- ParentWindowData *prev, *next;
-};
-
#define NMWLP_INCOMING 1
class CMsgDialog : public CSrmmBaseDialog
@@ -203,9 +164,16 @@ public:
LRESULT WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) override;
LRESULT WndProc_Nicklist(UINT msg, WPARAM wParam, LPARAM lParam) override;
- bool IsActive() const
- {
- return GetActiveWindow() == m_hwndParent && GetForegroundWindow() == m_hwndParent && m_pParent->hwndActive == m_hwnd;
+ __forceinline bool IsActive() const
+ { return GetActiveWindow() == m_hwndParent && GetForegroundWindow() == m_hwndParent && m_pParent->m_hwndActive == m_hwnd;
+ }
+
+ __forceinline void PopupWindow(bool bIncoming = false) const
+ { m_pParent->PopupWindow(m_hwnd, bIncoming);
+ }
+
+ __forceinline void StartFlashing() const
+ { m_pParent->StartFlashing();
}
wchar_t *m_wszInitialText;
diff --git a/plugins/Scriver/src/stdafx.h b/plugins/Scriver/src/stdafx.h
index 33164a84f1..7c11576c55 100644
--- a/plugins/Scriver/src/stdafx.h
+++ b/plugins/Scriver/src/stdafx.h
@@ -127,8 +127,8 @@ int StatusIconPressed(WPARAM wParam, LPARAM lParam);
#include "cmdlist.h"
#include "sendqueue.h"
#include "globals.h"
-#include "msgs.h"
#include "tabs.h"
+#include "msgs.h"
#include "utils.h"
#include "input.h"
#include "statusicon.h"
diff --git a/plugins/Scriver/src/tabs.cpp b/plugins/Scriver/src/tabs.cpp
index 00d6e7e065..dbeabcd992 100644
--- a/plugins/Scriver/src/tabs.cpp
+++ b/plugins/Scriver/src/tabs.cpp
@@ -33,32 +33,32 @@ static void DrawTab(ParentWindowData *dat, HWND hwnd, WPARAM wParam, LPARAM lPar
/////////////////////////////////////////////////////////////////////////////////////////
-static int GetChildCount(ParentWindowData *dat)
+int ParentWindowData::GetChildCount()
{
- return TabCtrl_GetItemCount(dat->hwndTabs);
+ return TabCtrl_GetItemCount(m_hwndTabs);
}
-static void GetChildWindowRect(ParentWindowData *dat, RECT *rcChild)
+void ParentWindowData::GetChildWindowRect(RECT *rcChild)
{
RECT rc, rcStatus, rcTabs;
- GetClientRect(dat->hwnd, &rc);
- GetClientRect(dat->hwndTabs, &rcTabs);
- TabCtrl_AdjustRect(dat->hwndTabs, FALSE, &rcTabs);
+ GetClientRect(m_hwnd, &rc);
+ GetClientRect(m_hwndTabs, &rcTabs);
+ TabCtrl_AdjustRect(m_hwndTabs, FALSE, &rcTabs);
rcStatus.top = rcStatus.bottom = 0;
- if (dat->flags2.bShowStatusBar)
- GetWindowRect(dat->hwndStatus, &rcStatus);
+ if (flags2.bShowStatusBar)
+ GetWindowRect(m_hwndStatus, &rcStatus);
rcChild->left = 0;
rcChild->right = rc.right;
- if (dat->flags2.bTabsAtBottom) {
+ if (flags2.bTabsAtBottom) {
rcChild->top = 2;
- if ((dat->flags2.bUseTabs && !(dat->flags2.bHideOneTab)) || (dat->childrenCount > 1))
+ if ((flags2.bUseTabs && !(flags2.bHideOneTab)) || (m_iChildrenCount > 1))
rcChild->bottom = rcTabs.bottom + 4;
else
rcChild->bottom = rc.bottom - rc.top - (rcStatus.bottom - rcStatus.top);
}
else {
- if ((dat->flags2.bUseTabs && !(dat->flags2.bHideOneTab)) || (dat->childrenCount > 1))
+ if ((flags2.bUseTabs && !(flags2.bHideOneTab)) || (m_iChildrenCount > 1))
rcChild->top = rcTabs.top;
else
rcChild->top = 2;
@@ -67,13 +67,13 @@ static void GetChildWindowRect(ParentWindowData *dat, RECT *rcChild)
}
}
-static int GetTabFromHWND(ParentWindowData *dat, HWND child)
+int ParentWindowData::GetTabFromHWND(HWND child)
{
- int l = TabCtrl_GetItemCount(dat->hwndTabs);
+ int l = TabCtrl_GetItemCount(m_hwndTabs);
for (int i = 0; i < l; i++) {
TCITEM tci = { 0 };
tci.mask = TCIF_PARAM;
- TabCtrl_GetItem(dat->hwndTabs, i, &tci);
+ TabCtrl_GetItem(m_hwndTabs, i, &tci);
CMsgDialog *pDlg = (CMsgDialog *)tci.lParam;
if (pDlg->GetHwnd() == child)
return i;
@@ -81,23 +81,23 @@ static int GetTabFromHWND(ParentWindowData *dat, HWND child)
return -1;
}
-static CMsgDialog* GetChildFromTab(HWND hwndTabs, int tabId)
+static CMsgDialog* GetChildFromTab(HWND m_hwndTabs, int tabId)
{
TCITEM tci = { 0 };
tci.mask = TCIF_PARAM;
- if (TabCtrl_GetItem(hwndTabs, tabId, &tci))
+ if (TabCtrl_GetItem(m_hwndTabs, tabId, &tci))
return (CMsgDialog *)tci.lParam;
return nullptr;
}
-static CMsgDialog* GetChildFromHWND(ParentWindowData *dat, HWND hwnd)
+CMsgDialog* ParentWindowData::GetChildFromHWND(HWND hwnd)
{
- int l = TabCtrl_GetItemCount(dat->hwndTabs);
+ int l = TabCtrl_GetItemCount(m_hwndTabs);
for (int i = 0; i < l; i++) {
TCITEM tci = { 0 };
tci.mask = TCIF_PARAM;
- TabCtrl_GetItem(dat->hwndTabs, i, &tci);
+ TabCtrl_GetItem(m_hwndTabs, i, &tci);
CMsgDialog *pDlg = (CMsgDialog *)tci.lParam;
if (pDlg->GetHwnd() == hwnd)
return pDlg;
@@ -110,10 +110,10 @@ static void GetMinimunWindowSize(ParentWindowData *dat, SIZE *size)
MINMAXINFO mmi;
RECT rc, rcWindow;
int minW = 216, minH = 80;
- GetWindowRect(dat->hwnd, &rcWindow);
- GetChildWindowRect(dat, &rc);
- for (int i = 0; i < dat->childrenCount; i++) {
- CMsgDialog * pDlg = GetChildFromTab(dat->hwndTabs, i);
+ GetWindowRect(dat->m_hwnd, &rcWindow);
+ dat->GetChildWindowRect(&rc);
+ for (int i = 0; i < dat->m_iChildrenCount; i++) {
+ CMsgDialog * pDlg = GetChildFromTab(dat->m_hwndTabs, i);
SendMessage(pDlg->GetHwnd(), WM_GETMINMAXINFO, 0, (LPARAM)&mmi);
if (i == 0 || mmi.ptMinTrackSize.x > minW) minW = mmi.ptMinTrackSize.x;
if (i == 0 || mmi.ptMinTrackSize.y > minH) minH = mmi.ptMinTrackSize.y;
@@ -130,17 +130,17 @@ static void GetMinimunWindowSize(ParentWindowData *dat, SIZE *size)
static void SetupStatusBar(ParentWindowData *dat)
{
- int statusIconNum = GetStatusIconsCount(dat->hContact);
+ int statusIconNum = GetStatusIconsCount(dat->m_hContact);
int statwidths[4];
RECT rc;
- GetClientRect(dat->hwnd, &rc);
+ GetClientRect(dat->m_hwnd, &rc);
statwidths[0] = rc.right - rc.left - SB_CHAR_WIDTH - SB_UNICODE_WIDTH - 2 * (statusIconNum > 0) - statusIconNum * (GetSystemMetrics(SM_CXSMICON) + 2);
statwidths[1] = rc.right - rc.left - SB_UNICODE_WIDTH - 2 * (statusIconNum > 0) - statusIconNum * (GetSystemMetrics(SM_CXSMICON) + 2);
statwidths[2] = rc.right - rc.left - SB_UNICODE_WIDTH;
statwidths[3] = -1;
- SendMessage(dat->hwndStatus, SB_SETPARTS, 4, (LPARAM)statwidths);
- SendMessage(dat->hwndStatus, SB_SETTEXT, (WPARAM)(SBT_OWNERDRAW) | 2, 0);
- SendMessage(dat->hwndStatus, SB_SETTEXT, (WPARAM)(SBT_NOBORDERS) | 3, 0);
+ SendMessage(dat->m_hwndStatus, SB_SETPARTS, 4, (LPARAM)statwidths);
+ SendMessage(dat->m_hwndStatus, SB_SETTEXT, (WPARAM)(SBT_OWNERDRAW) | 2, 0);
+ SendMessage(dat->m_hwndStatus, SB_SETTEXT, (WPARAM)(SBT_NOBORDERS) | 3, 0);
}
static int AddOrReplaceIcon(HIMAGELIST hList, int prevIndex, HICON hIcon)
@@ -174,146 +174,256 @@ static void ReleaseIcon(int index)
g_dat.tabIconListUsage[i].used = 0;
}
-static void ActivateChild(ParentWindowData *dat, HWND child)
+void ParentWindowData::ActivateChild(HWND child)
{
RECT rcChild;
- GetChildWindowRect(dat, &rcChild);
+ GetChildWindowRect(&rcChild);
SetWindowPos(child, HWND_TOP, rcChild.left, rcChild.top, rcChild.right - rcChild.left, rcChild.bottom - rcChild.top, 0);
- int i = GetTabFromHWND(dat, child);
+ int i = GetTabFromHWND(child);
if (i == -1)
return;
- CMsgDialog *pDlg = GetChildFromTab(dat->hwndTabs, i);
+ CMsgDialog *pDlg = GetChildFromTab(m_hwndTabs, i);
if (pDlg == nullptr)
return;
- dat->hContact = pDlg->m_hContact;
- if (child != dat->hwndActive) {
- HWND prev = dat->hwndActive;
- dat->hwndActive = child;
- SetupStatusBar(dat);
+ m_hContact = pDlg->m_hContact;
+ if (child != m_hwndActive) {
+ HWND hwndPrev = m_hwndActive;
+ m_hwndActive = child;
+ SetupStatusBar(this);
pDlg->UpdateStatusBar();
pDlg->UpdateTitle();
- SendMessage(dat->hwndActive, WM_SIZE, 0, 0);
- ShowWindow(dat->hwndActive, SW_SHOWNOACTIVATE);
+ SendMessage(m_hwndActive, WM_SIZE, 0, 0);
+ ShowWindow(m_hwndActive, SW_SHOWNOACTIVATE);
pDlg->ScrollToBottom();
- if (prev != nullptr)
- ShowWindow(prev, SW_HIDE);
+ if (hwndPrev != nullptr)
+ ShowWindow(hwndPrev, SW_HIDE);
}
- else SendMessage(dat->hwnd, WM_SIZE, 0, 0);
+ else SendMessage(m_hwnd, WM_SIZE, 0, 0);
- TabCtrl_SetCurSel(dat->hwndTabs, i);
- SendMessage(dat->hwndActive, DM_ACTIVATE, WA_ACTIVE, 0);
+ TabCtrl_SetCurSel(m_hwndTabs, i);
+ SendMessage(m_hwndActive, DM_ACTIVATE, WA_ACTIVE, 0);
}
-static void AddChild(ParentWindowData *dat, CMsgDialog *pDlg)
+void ParentWindowData::AddChild(CMsgDialog *pDlg)
{
- dat->childrenCount++;
+ m_iChildrenCount++;
TCITEM tci;
tci.mask = TCIF_PARAM | TCIF_IMAGE | TCIF_TEXT;
tci.lParam = (LPARAM)pDlg;
tci.iImage = -1;
tci.pszText = L"";
- TabCtrl_InsertItem(dat->hwndTabs, dat->childrenCount - 1, &tci);
- SetWindowPos(pDlg->GetHwnd(), HWND_TOP, dat->childRect.left, dat->childRect.top, dat->childRect.right - dat->childRect.left, dat->childRect.bottom - dat->childRect.top, SWP_HIDEWINDOW);
- SendMessage(dat->hwnd, WM_SIZE, 0, 0);
+ TabCtrl_InsertItem(m_hwndTabs, m_iChildrenCount - 1, &tci);
+ SetWindowPos(pDlg->GetHwnd(), HWND_TOP, childRect.left, childRect.top, childRect.right - childRect.left, childRect.bottom - childRect.top, SWP_HIDEWINDOW);
+ SendMessage(m_hwnd, WM_SIZE, 0, 0);
EnableThemeDialogTexture(pDlg->GetHwnd(), ETDT_ENABLETAB);
}
-static void RemoveChild(ParentWindowData *dat, HWND child)
+void ParentWindowData::RemoveChild(HWND child)
{
- int tab = GetTabFromHWND(dat, child);
+ int tab = GetTabFromHWND(child);
if (tab >= 0) {
TCITEM tci;
tci.mask = TCIF_PARAM | TCIF_IMAGE;
- TabCtrl_GetItem(dat->hwndTabs, tab, &tci);
- TabCtrl_DeleteItem(dat->hwndTabs, tab);
- dat->childrenCount--;
- if (child == dat->hwndActive) {
- if (tab == TabCtrl_GetItemCount(dat->hwndTabs)) tab--;
+ TabCtrl_GetItem(m_hwndTabs, tab, &tci);
+ TabCtrl_DeleteItem(m_hwndTabs, tab);
+ m_iChildrenCount--;
+ if (child == m_hwndActive) {
+ if (tab == TabCtrl_GetItemCount(m_hwndTabs)) tab--;
if (tab >= 0)
- ActivateChild(dat, GetChildFromTab(dat->hwndTabs, tab)->GetHwnd());
+ ActivateChild(GetChildFromTab(m_hwndTabs, tab)->GetHwnd());
else
- dat->hwndActive = nullptr;
+ m_hwndActive = nullptr;
}
ReleaseIcon(tci.iImage);
}
+
+ if (m_iChildrenCount != 0)
+ SetFocus(m_hwndActive);
+ else
+ PostMessage(m_hwnd, WM_CLOSE, 0, 0);
}
-static void CloseOtherChilden(ParentWindowData *dat, HWND child)
+void ParentWindowData::CloseOtherChilden(CMsgDialog *pChildDlg)
{
- ActivateChild(dat, child);
- for (int i = dat->childrenCount - 1; i >= 0; i--) {
- CMsgDialog *pDlg = GetChildFromTab(dat->hwndTabs, i);
- if (pDlg != nullptr && pDlg->GetHwnd() != child)
+ ActivateChild(pChildDlg->GetHwnd());
+
+ for (int i = m_iChildrenCount - 1; i >= 0; i--) {
+ CMsgDialog *pDlg = GetChildFromTab(m_hwndTabs, i);
+ if (pDlg != nullptr && pDlg != pChildDlg)
pDlg->Close();
}
- ActivateChild(dat, child);
+
+ ActivateChild(pChildDlg->GetHwnd());
}
-static void ActivateNextChild(ParentWindowData *dat, HWND child)
+void ParentWindowData::ActivateNextChild(HWND child)
{
- int i = GetTabFromHWND(dat, child);
- int l = TabCtrl_GetItemCount(dat->hwndTabs);
+ int i = GetTabFromHWND(child);
+ int l = TabCtrl_GetItemCount(m_hwndTabs);
i = (i + 1) % l;
- ActivateChild(dat, GetChildFromTab(dat->hwndTabs, i)->GetHwnd());
+ ActivateChild(GetChildFromTab(m_hwndTabs, i)->GetHwnd());
+ SetFocus(m_hwndActive);
}
-static void ActivatePrevChild(ParentWindowData *dat, HWND child)
+void ParentWindowData::ActivatePrevChild(HWND child)
{
- int i = GetTabFromHWND(dat, child);
- int l = TabCtrl_GetItemCount(dat->hwndTabs);
+ int i = GetTabFromHWND(child);
+ int l = TabCtrl_GetItemCount(m_hwndTabs);
i = (i + l - 1) % l;
- ActivateChild(dat, GetChildFromTab(dat->hwndTabs, i)->GetHwnd());
+ ActivateChild(GetChildFromTab(m_hwndTabs, i)->GetHwnd());
+ SetFocus(m_hwndActive);
}
-static void ActivateChildByIndex(ParentWindowData *dat, int index)
+void ParentWindowData::ActivateChildByIndex(int index)
{
- int l = TabCtrl_GetItemCount(dat->hwndTabs);
+ int l = TabCtrl_GetItemCount(m_hwndTabs);
if (index < l) {
- CMsgDialog *pDlg = GetChildFromTab(dat->hwndTabs, index);
+ CMsgDialog *pDlg = GetChildFromTab(m_hwndTabs, index);
if (pDlg != nullptr)
- ActivateChild(dat, pDlg->GetHwnd());
+ ActivateChild(pDlg->GetHwnd());
}
+ SetFocus(m_hwndActive);
}
-static void SetContainerWindowStyle(ParentWindowData *dat)
+void ParentWindowData::PopupWindow(HWND hwnd, bool bIncoming)
{
- ShowWindow(dat->hwndStatus, (dat->flags2.bShowStatusBar) ? SW_SHOW : SW_HIDE);
+ EnableWindow(m_hwnd, TRUE);
+ if (bIncoming) { /* incoming message */
+ if (g_dat.flags.bStayMinimized) {
+ if (!IsWindowVisible(m_hwnd))
+ ShowWindow(m_hwnd, SW_SHOWMINNOACTIVE);
+
+ if (m_iChildrenCount == 1 || (g_dat.flags2.bSwitchToActive && (IsIconic(m_hwnd) || GetForegroundWindow() != m_hwnd)))
+ ActivateChild(hwnd);
+ }
+ else {
+ ShowWindow(m_hwnd, IsIconic(m_hwnd) ? SW_SHOWNORMAL : SW_SHOWNA);
+
+ if (m_iChildrenCount == 1 || (g_dat.flags2.bSwitchToActive && (IsIconic(m_hwnd) || GetForegroundWindow() != m_hwnd)))
+ ActivateChild(hwnd);
- DWORD ws = GetWindowLongPtr(dat->hwnd, GWL_STYLE) & ~(WS_CAPTION);
- if (dat->flags2.bShowTitleBar)
+ SetWindowPos(m_hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
+ }
+ }
+ else { /* outgoing message */
+ ShowWindow(m_hwnd, IsIconic(m_hwnd) ? SW_SHOWNORMAL : SW_SHOW);
+ SetForegroundWindow(m_hwnd);
+ SetFocus(hwnd);
+ }
+}
+
+void ParentWindowData::SetContainerWindowStyle()
+{
+ ShowWindow(m_hwndStatus, (flags2.bShowStatusBar) ? SW_SHOW : SW_HIDE);
+
+ DWORD ws = GetWindowLongPtr(m_hwnd, GWL_STYLE) & ~(WS_CAPTION);
+ if (flags2.bShowTitleBar)
ws |= WS_CAPTION;
- SetWindowLongPtr(dat->hwnd, GWL_STYLE, ws);
+ SetWindowLongPtr(m_hwnd, GWL_STYLE, ws);
- ws = GetWindowLongPtr(dat->hwnd, GWL_EXSTYLE)& ~WS_EX_LAYERED;
- ws |= dat->flags2.bUseTransparency ? WS_EX_LAYERED : 0;
- SetWindowLongPtr(dat->hwnd, GWL_EXSTYLE, ws);
- if (dat->flags2.bUseTransparency)
- SetLayeredWindowAttributes(dat->hwnd, RGB(255, 255, 255), (BYTE)(255 - g_dat.inactiveAlpha), LWA_ALPHA);
+ ws = GetWindowLongPtr(m_hwnd, GWL_EXSTYLE)& ~WS_EX_LAYERED;
+ ws |= flags2.bUseTransparency ? WS_EX_LAYERED : 0;
+ SetWindowLongPtr(m_hwnd, GWL_EXSTYLE, ws);
+ if (flags2.bUseTransparency)
+ SetLayeredWindowAttributes(m_hwnd, RGB(255, 255, 255), (BYTE)(255 - g_dat.inactiveAlpha), LWA_ALPHA);
- ws = GetWindowLongPtr(dat->hwndTabs, GWL_STYLE) & ~(TCS_BOTTOM | 0x2000);
- if (dat->flags2.bTabsAtBottom)
+ ws = GetWindowLongPtr(m_hwndTabs, GWL_STYLE) & ~(TCS_BOTTOM | 0x2000);
+ if (flags2.bTabsAtBottom)
ws |= TCS_BOTTOM;
ws |= 0x2000;
- if (dat->flags2.bTabCloseButton)
- TabCtrl_SetPadding(dat->hwndTabs, GetSystemMetrics(SM_CXEDGE) + 12, GetSystemMetrics(SM_CYEDGE) + 1);
+ if (flags2.bTabCloseButton)
+ TabCtrl_SetPadding(m_hwndTabs, GetSystemMetrics(SM_CXEDGE) + 12, GetSystemMetrics(SM_CYEDGE) + 1);
else
- TabCtrl_SetPadding(dat->hwndTabs, GetSystemMetrics(SM_CXEDGE) + 4, GetSystemMetrics(SM_CYEDGE) + 1);
+ TabCtrl_SetPadding(m_hwndTabs, GetSystemMetrics(SM_CXEDGE) + 4, GetSystemMetrics(SM_CYEDGE) + 1);
- SetWindowLongPtr(dat->hwndTabs, GWL_STYLE, ws);
+ SetWindowLongPtr(m_hwndTabs, GWL_STYLE, ws);
RECT rc;
- GetWindowRect(dat->hwnd, &rc);
- SetWindowPos(dat->hwnd, nullptr, 0, 0, rc.right - rc.left, rc.bottom - rc.top,
+ GetWindowRect(m_hwnd, &rc);
+ SetWindowPos(m_hwnd, nullptr, 0, 0, rc.right - rc.left, rc.bottom - rc.top,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOSENDCHANGING);
}
+void ParentWindowData::StartFlashing()
+{
+ if ((GetActiveWindow() != m_hwnd || GetForegroundWindow() != m_hwnd)) {
+ nFlash = 0;
+ SetTimer(m_hwnd, TIMERID_FLASHWND, TIMEOUT_FLASHWND, nullptr);
+ }
+}
+
+void ParentWindowData::UpdateStatusBar(const StatusBarData &sbd, HWND hwnd)
+{
+ if (m_hwndActive == hwnd) {
+ if (sbd.iFlags & SBDF_TEXT)
+ SendMessage(m_hwndStatus, SB_SETTEXT, sbd.iItem, (LPARAM)sbd.pszText);
+ if (sbd.iFlags & SBDF_ICON)
+ SendMessage(m_hwndStatus, SB_SETICON, sbd.iItem, (LPARAM)sbd.hIcon);
+ }
+ RedrawWindow(m_hwndStatus, nullptr, nullptr, RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW);
+}
+
+void ParentWindowData::UpdateTabControl(const TabControlData &tcd, HWND hwnd)
+{
+ int tabId = GetTabFromHWND(hwnd);
+ if (tabId < 0)
+ return;
+
+ wchar_t *ptszTemp = nullptr;
+
+ TCITEM tci;
+ tci.mask = 0;
+ if (tcd.iFlags & TCDF_TEXT) {
+ tci.mask |= TCIF_TEXT;
+ tci.pszText = tcd.pszText;
+ if (g_dat.flags2.bLimitNames) {
+ wchar_t *ltext = limitText(tcd.pszText, g_dat.limitNamesLength);
+ if (ltext != tcd.pszText)
+ tci.pszText = ptszTemp = ltext;
+ }
+ }
+ if (tcd.iFlags & TCDF_ICON) {
+ int iconIdx = -1;
+ if (tcd.hIcon != nullptr) {
+ TCITEM tci2;
+ tci2.mask = TCIF_IMAGE;
+ TabCtrl_GetItem(m_hwndTabs, tabId, &tci2);
+ iconIdx = AddOrReplaceIcon(g_dat.hTabIconList, tci2.iImage, tcd.hIcon);
+ }
+ tci.mask |= TCIF_IMAGE;
+ tci.iImage = iconIdx;
+ }
+ TabCtrl_SetItem(m_hwndTabs, tabId, &tci);
+ mir_free(ptszTemp);
+}
+
+void ParentWindowData::UpdateTitleBar(const TitleBarData &tbd, HWND hwnd)
+{
+ if (m_hwndActive != hwnd)
+ return;
+
+ if (tbd.iFlags & TBDF_TEXT) {
+ wchar_t oldtitle[256];
+ GetWindowText(m_hwnd, oldtitle, _countof(oldtitle));
+ if (mir_wstrcmp(tbd.pszText, oldtitle))
+ SetWindowText(m_hwnd, tbd.pszText);
+ }
+ if (tbd.iFlags & TBDF_ICON) {
+ SendMessage(m_hwnd, WM_SETICON, ICON_SMALL, (LPARAM)tbd.hIcon);
+ if (tbd.hIconBig != nullptr)
+ SendMessage(m_hwnd, WM_SETICON, ICON_BIG, (LPARAM)tbd.hIconBig);
+ if (pTaskbarInterface)
+ pTaskbarInterface->SetOverlayIcon(m_hwnd, tbd.hIconNot, L"");
+ }
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
static LRESULT CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -588,11 +698,11 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
int savePerContact = g_plugin.bSavePerContact && !g_dat.flags2.bUseTabs;
NewMessageWindowLParam *newData = (NewMessageWindowLParam *)lParam;
dat = (ParentWindowData *)mir_alloc(sizeof(ParentWindowData));
- dat->hContact = newData->hContact;
+ dat->m_hContact = newData->hContact;
dat->nFlash = 0;
dat->nFlashMax = g_plugin.iFlashCount;
- dat->childrenCount = 0;
- dat->hwnd = hwndDlg;
+ dat->m_iChildrenCount = 0;
+ dat->m_hwnd = hwndDlg;
dat->mouseLBDown = 0;
dat->windowWasCascaded = 0;
dat->bMinimized = 0;
@@ -600,15 +710,15 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
dat->iSplitterX = g_plugin.getDword("splitterx", -1);
dat->iSplitterY = g_plugin.getDword("splittery", -1);
dat->flags2 = g_dat.flags2;
- dat->hwndStatus = CreateWindowEx(0, STATUSCLASSNAME, nullptr, WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP, 0, 0, 0, 0, hwndDlg, nullptr, g_plugin.getInst(), nullptr);
+ dat->m_hwndStatus = CreateWindowEx(0, STATUSCLASSNAME, nullptr, WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP, 0, 0, 0, 0, hwndDlg, nullptr, g_plugin.getInst(), nullptr);
dat->isChat = newData->isChat;
- SendMessage(dat->hwndStatus, SB_SETMINHEIGHT, GetSystemMetrics(SM_CYSMICON), 0);
+ SendMessage(dat->m_hwndStatus, SB_SETMINHEIGHT, GetSystemMetrics(SM_CYSMICON), 0);
SetupStatusBar(dat);
- dat->hwndTabs = GetDlgItem(hwndDlg, IDC_TABS);
- dat->hwndActive = nullptr;
+ dat->m_hwndTabs = GetDlgItem(hwndDlg, IDC_TABS);
+ dat->m_hwndActive = nullptr;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
if (g_dat.hTabIconList != nullptr)
- TabCtrl_SetImageList(dat->hwndTabs, g_dat.hTabIconList);
+ TabCtrl_SetImageList(dat->m_hwndTabs, g_dat.hTabIconList);
dat->next = nullptr;
if (!newData->isChat) {
@@ -623,11 +733,11 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
dat->prev->next = dat;
WindowList_Add(g_dat.hParentWindowList, hwndDlg, (UINT_PTR)hwndDlg);
- SubclassTabCtrl(dat->hwndTabs);
+ SubclassTabCtrl(dat->m_hwndTabs);
- SetContainerWindowStyle(dat);
+ dat->SetContainerWindowStyle();
- MCONTACT hSContact = savePerContact ? dat->hContact : 0;
+ MCONTACT hSContact = savePerContact ? dat->m_hContact : 0;
dat->bTopmost = g_plugin.bTopmost;
if (Utils_RestoreWindowPosition(hwndDlg, hSContact, SRMM_MODULE, (newData->isChat && !savePerContact) ? "chat" : "", RWPF_HIDDEN))
SetWindowPos(hwndDlg, nullptr, 0, 0, 450, 300, SWP_NOZORDER | SWP_NOMOVE | SWP_HIDEWINDOW);
@@ -682,7 +792,7 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
dat->bMinimized = 1;
if (IsIconic(hwndDlg))
- MoveWindow(dat->hwndActive, dat->childRect.left, dat->childRect.top, dat->childRect.right - dat->childRect.left, dat->childRect.bottom - dat->childRect.top, TRUE);
+ MoveWindow(dat->m_hwndActive, dat->childRect.left, dat->childRect.top, dat->childRect.right - dat->childRect.left, dat->childRect.bottom - dat->childRect.top, TRUE);
else {
RECT rcStatus, rcChild, rcWindow, rc;
SIZE size;
@@ -691,11 +801,11 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
GetWindowRect(hwndDlg, &rcWindow);
rcStatus.top = rcStatus.bottom = 0;
if (dat->flags2.bShowStatusBar) {
- GetWindowRect(dat->hwndStatus, &rcStatus);
+ GetWindowRect(dat->m_hwndStatus, &rcStatus);
SetupStatusBar(dat);
}
- MoveWindow(dat->hwndTabs, 0, 2, (rc.right - rc.left), (rc.bottom - rc.top) - (rcStatus.bottom - rcStatus.top) - 2, FALSE);
- RedrawWindow(dat->hwndTabs, nullptr, nullptr, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE);
+ MoveWindow(dat->m_hwndTabs, 0, 2, (rc.right - rc.left), (rc.bottom - rc.top) - (rcStatus.bottom - rcStatus.top) - 2, FALSE);
+ RedrawWindow(dat->m_hwndTabs, nullptr, nullptr, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE);
GetMinimunWindowSize(dat, &size);
if ((rcWindow.bottom - rcWindow.top) < size.cy || (rcWindow.right - rcWindow.left) < size.cx) {
if ((rcWindow.bottom - rcWindow.top) < size.cy)
@@ -704,24 +814,24 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
rcWindow.right = rcWindow.left + size.cx;
MoveWindow(hwndDlg, rcWindow.left, rcWindow.top, rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top, TRUE);
}
- GetChildWindowRect(dat, &rcChild);
+ dat->GetChildWindowRect(&rcChild);
dat->childRect = rcChild;
- MoveWindow(dat->hwndActive, rcChild.left, rcChild.top, rcChild.right - rcChild.left, rcChild.bottom - rcChild.top, TRUE);
- RedrawWindow(GetDlgItem(dat->hwndActive, IDC_SRMM_LOG), nullptr, nullptr, RDW_INVALIDATE);
+ MoveWindow(dat->m_hwndActive, rcChild.left, rcChild.top, rcChild.right - rcChild.left, rcChild.bottom - rcChild.top, TRUE);
+ RedrawWindow(GetDlgItem(dat->m_hwndActive, IDC_SRMM_LOG), nullptr, nullptr, RDW_INVALIDATE);
if (dat->flags2.bShowStatusBar) {
- SendMessage(dat->hwndStatus, WM_SIZE, 0, 0);
- RedrawWindow(dat->hwndStatus, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE);
+ SendMessage(dat->m_hwndStatus, WM_SIZE, 0, 0);
+ RedrawWindow(dat->m_hwndStatus, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE);
}
}
return FALSE;
case WM_SETFOCUS:
- if (dat->hwndActive != nullptr)
- SetFocus(dat->hwndActive);
+ if (dat->m_hwndActive != nullptr)
+ SetFocus(dat->m_hwndActive);
return TRUE;
case WM_CLOSE:
- if (g_dat.flags2.bHideContainer && dat->childrenCount > 0)
+ if (g_dat.flags2.bHideContainer && dat->m_iChildrenCount > 0)
ShowWindow(hwndDlg, SW_HIDE);
else
DestroyWindow(hwndDlg);
@@ -733,21 +843,21 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
case WM_DRAWITEM:
{
LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam;
- if (dat && dat->hwndActive && dis->hwndItem == dat->hwndStatus) {
- CMsgDialog *pDlg = GetChildFromHWND(dat, dat->hwndActive);
+ if (dat && dat->m_hwndActive && dis->hwndItem == dat->m_hwndStatus) {
+ CMsgDialog *pDlg = dat->GetChildFromHWND(dat->m_hwndActive);
if (pDlg != nullptr)
DrawStatusIcons(pDlg->m_hContact, dis->hDC, dis->rcItem, 2);
return TRUE;
}
- if (dis->hwndItem == dat->hwndTabs) {
- DrawTab(dat, dat->hwndTabs, wParam, lParam);
+ if (dis->hwndItem == dat->m_hwndTabs) {
+ DrawTab(dat, dat->m_hwndTabs, wParam, lParam);
return TRUE;
}
}
return Menu_DrawItem(lParam);
case WM_COMMAND:
- if (Clist_MenuProcessCommand(LOWORD(wParam), MPCF_CONTACTMENU, dat->hContact))
+ if (Clist_MenuProcessCommand(LOWORD(wParam), MPCF_CONTACTMENU, dat->m_hContact))
break;
if (LOWORD(wParam) == IDCANCEL)
@@ -757,17 +867,17 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
case WM_NOTIFY:
{
NMHDR *pNMHDR = (NMHDR*)lParam;
- if (pNMHDR->hwndFrom == dat->hwndTabs) {
+ if (pNMHDR->hwndFrom == dat->m_hwndTabs) {
switch (pNMHDR->code) {
case TCN_SELCHANGE:
{
TCITEM tci = { 0 };
- int iSel = TabCtrl_GetCurSel(dat->hwndTabs);
+ int iSel = TabCtrl_GetCurSel(dat->m_hwndTabs);
tci.mask = TCIF_PARAM;
- if (TabCtrl_GetItem(dat->hwndTabs, iSel, &tci)) {
+ if (TabCtrl_GetItem(dat->m_hwndTabs, iSel, &tci)) {
CMsgDialog * pDlg = (CMsgDialog *)tci.lParam;
- ActivateChild(dat, pDlg->GetHwnd());
- SetFocus(dat->hwndActive);
+ dat->ActivateChild(pDlg->GetHwnd());
+ SetFocus(dat->m_hwndActive);
}
}
break;
@@ -778,10 +888,10 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
int x = thinfo.pt.x;
int y = thinfo.pt.y;
- ScreenToClient(dat->hwndTabs, &thinfo.pt);
- int tabId = TabCtrl_HitTest(dat->hwndTabs, &thinfo);
+ ScreenToClient(dat->m_hwndTabs, &thinfo.pt);
+ int tabId = TabCtrl_HitTest(dat->m_hwndTabs, &thinfo);
if (tabId != -1) {
- CMsgDialog *pDlg = GetChildFromTab(dat->hwndTabs, tabId);
+ CMsgDialog *pDlg = GetChildFromTab(dat->m_hwndTabs, tabId);
HMENU hMenu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_CONTEXT));
HMENU hSubMenu = GetSubMenu(hMenu, 3);
TranslateMenu(hSubMenu);
@@ -796,7 +906,7 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
SendMessage(pDlg->GetHwnd(), WM_CLOSE, 0, 0);
break;
case IDM_CLOSEOTHERTABS:
- CloseOtherChilden(dat, pDlg->GetHwnd());
+ dat->CloseOtherChilden(pDlg);
break;
default:
Clist_MenuProcessCommand(LOWORD(menuResult), MPCF_CONTACTMENU, pDlg->m_hContact);
@@ -808,16 +918,16 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
}
break;
}
- else if (pNMHDR->hwndFrom == dat->hwndStatus) {
+ else if (pNMHDR->hwndFrom == dat->m_hwndStatus) {
switch (pNMHDR->code) {
case NM_CLICK:
RECT rc;
NMMOUSE *nm = (NMMOUSE*)lParam;
- SendMessage(dat->hwndStatus, SB_GETRECT, SendMessage(dat->hwndStatus, SB_GETPARTS, 0, 0) - 2, (LPARAM)&rc);
+ SendMessage(dat->m_hwndStatus, SB_GETRECT, SendMessage(dat->m_hwndStatus, SB_GETPARTS, 0, 0) - 2, (LPARAM)&rc);
if (nm->pt.x >= rc.left) {
- CMsgDialog *pDlg = GetChildFromHWND(dat, dat->hwndActive);
+ CMsgDialog *pDlg = dat->GetChildFromHWND(dat->m_hwndActive);
if (pDlg != nullptr)
- CheckStatusIconClick(pDlg->m_hContact, dat->hwndStatus, nm->pt, rc, 2, 0);
+ CheckStatusIconClick(pDlg->m_hContact, dat->m_hwndStatus, nm->pt, rc, 2, 0);
}
return TRUE;
}
@@ -826,7 +936,7 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
break;
case WM_DROPFILES:
- SendMessage(dat->hwndActive, WM_DROPFILES, wParam, lParam);
+ SendMessage(dat->m_hwndActive, WM_DROPFILES, wParam, lParam);
break;
case WM_TIMER:
@@ -843,21 +953,21 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
break;
case WM_CONTEXTMENU:
- if (dat->hwndStatus && dat->hwndStatus == (HWND)wParam) {
+ if (dat->m_hwndStatus && dat->m_hwndStatus == (HWND)wParam) {
POINT pt, pt2;
GetCursorPos(&pt);
pt2 = pt;
- ScreenToClient(dat->hwndStatus, &pt);
+ ScreenToClient(dat->m_hwndStatus, &pt);
RECT rc;
- SendMessage(dat->hwndStatus, SB_GETRECT, SendMessage(dat->hwndStatus, SB_GETPARTS, 0, 0) - 2, (LPARAM)&rc);
+ SendMessage(dat->m_hwndStatus, SB_GETRECT, SendMessage(dat->m_hwndStatus, SB_GETPARTS, 0, 0) - 2, (LPARAM)&rc);
if (pt.x >= rc.left) {
- CMsgDialog *pDlg = GetChildFromHWND(dat, dat->hwndActive);
+ CMsgDialog *pDlg = dat->GetChildFromHWND(dat->m_hwndActive);
if (pDlg != nullptr)
- CheckStatusIconClick(pDlg->m_hContact, dat->hwndStatus, pt, rc, 2, MBCF_RIGHTBUTTON);
+ CheckStatusIconClick(pDlg->m_hContact, dat->m_hwndStatus, pt, rc, 2, MBCF_RIGHTBUTTON);
break;
}
- else SendMessage(dat->hwndActive, WM_CONTEXTMENU, (WPARAM)hwndDlg, 0);
+ else SendMessage(dat->m_hwndActive, WM_CONTEXTMENU, (WPARAM)hwndDlg, 0);
}
break;
@@ -870,10 +980,10 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
SetLayeredWindowAttributes(hwndDlg, RGB(255, 255, 255), (BYTE)(255 - g_dat.inactiveAlpha), LWA_ALPHA);
break;
}
- if (dat->hwndActive != nullptr) {
- ActivateChild(dat, dat->hwndActive);
- g_dat.hFocusWnd = dat->hwndActive;
- PostMessage(dat->hwndActive, DM_SETFOCUS, 0, msg);
+ if (dat->m_hwndActive != nullptr) {
+ dat->ActivateChild(dat->m_hwndActive);
+ g_dat.hFocusWnd = dat->m_hwndActive;
+ PostMessage(dat->m_hwndActive, DM_SETFOCUS, 0, msg);
}
if (KillTimer(hwndDlg, TIMERID_FLASHWND)) {
FlashWindow(hwndDlg, FALSE);
@@ -961,12 +1071,12 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
break;
case WM_DESTROY:
- for (int i = dat->childrenCount; i >= 0; i--) {
+ for (int i = dat->m_iChildrenCount; i >= 0; i--) {
TCITEM tci;
tci.mask = TCIF_PARAM | TCIF_IMAGE;
- if (TabCtrl_GetItem(dat->hwndTabs, i, &tci)) {
+ if (TabCtrl_GetItem(dat->m_hwndTabs, i, &tci)) {
ReleaseIcon(tci.iImage);
- TabCtrl_DeleteItem(dat->hwndTabs, i);
+ TabCtrl_DeleteItem(dat->m_hwndTabs, i);
}
}
@@ -977,7 +1087,7 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
WindowList_Remove(g_dat.hParentWindowList, hwndDlg);
{
int savePerContact = g_plugin.bSavePerContact && !dat->flags2.bUseTabs;
- MCONTACT hContact = (savePerContact) ? dat->hContact : 0;
+ MCONTACT hContact = (savePerContact) ? dat->m_hContact : 0;
Utils_SaveWindowPosition(hwndDlg, hContact, SRMM_MODULE, (!savePerContact && dat->isChat) ? "chat" : "");
g_plugin.bTopmost = dat->bTopmost;
}
@@ -994,173 +1104,34 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
if (dat->next != nullptr)
dat->next->prev = dat->prev;
- UnsubclassTabCtrl(dat->hwndTabs);
+ UnsubclassTabCtrl(dat->m_hwndTabs);
mir_free(dat);
break;
- case CM_STARTFLASHING:
- if ((GetActiveWindow() != hwndDlg || GetForegroundWindow() != hwndDlg)) {
- dat->nFlash = 0;
- SetTimer(hwndDlg, TIMERID_FLASHWND, TIMEOUT_FLASHWND, nullptr);
- }
- break;
-
- case CM_POPUPWINDOW:
- EnableWindow(hwndDlg, TRUE);
- if (wParam) { /* incoming message */
- if (g_dat.flags.bStayMinimized) {
- if (!IsWindowVisible(hwndDlg))
- ShowWindow(hwndDlg, SW_SHOWMINNOACTIVE);
-
- if (dat->childrenCount == 1 || (g_dat.flags2.bSwitchToActive && (IsIconic(hwndDlg) || GetForegroundWindow() != hwndDlg)))
- SendMessage(hwndDlg, CM_ACTIVATECHILD, 0, (LPARAM)lParam);
- }
- else {
- ShowWindow(hwndDlg, IsIconic(hwndDlg) ? SW_SHOWNORMAL : SW_SHOWNA);
-
- if (dat->childrenCount == 1 || (g_dat.flags2.bSwitchToActive && (IsIconic(hwndDlg) || GetForegroundWindow() != hwndDlg)))
- SendMessage(hwndDlg, CM_ACTIVATECHILD, 0, (LPARAM)lParam);
-
- SetWindowPos(hwndDlg, HWND_TOP, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
- }
- }
- else { /* outgoing message */
- ShowWindow(hwndDlg, IsIconic(hwndDlg) ? SW_SHOWNORMAL : SW_SHOW);
- SetForegroundWindow(hwndDlg);
- SetFocus((HWND)lParam);
- }
- break;
-
- case CM_REMOVECHILD:
- RemoveChild(dat, (HWND)lParam);
- if (dat->childrenCount != 0)
- SetFocus(dat->hwndActive);
- else
- PostMessage(hwndDlg, WM_CLOSE, 0, 0);
- return TRUE;
-
- case CM_ADDCHILD:
- AddChild(dat, (CMsgDialog*)wParam);
- return TRUE;
-
- case CM_ACTIVATECHILD:
- ActivateChild(dat, (HWND)lParam);
- return TRUE;
-
- case CM_ACTIVATEPREV:
- ActivatePrevChild(dat, (HWND)lParam);
- SetFocus(dat->hwndActive);
- return TRUE;
-
- case CM_ACTIVATENEXT:
- ActivateNextChild(dat, (HWND)lParam);
- SetFocus(dat->hwndActive);
- return TRUE;
-
- case CM_ACTIVATEBYINDEX:
- ActivateChildByIndex(dat, (int)lParam);
- SetFocus(dat->hwndActive);
- return TRUE;
-
- case CM_GETCHILDCOUNT:
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, (LONG_PTR)GetChildCount(dat));
- return TRUE;
-
case DM_SENDMESSAGE:
- for (int i = 0; i < dat->childrenCount; i++) {
- CMsgDialog * pDlg = GetChildFromTab(dat->hwndTabs, i);
+ for (int i = 0; i < dat->m_iChildrenCount; i++) {
+ CMsgDialog * pDlg = GetChildFromTab(dat->m_hwndTabs, i);
SendMessage(pDlg->GetHwnd(), DM_SENDMESSAGE, wParam, lParam);
}
break;
case DM_OPTIONSAPPLIED:
dat->flags2 = g_dat.flags2;
- SetContainerWindowStyle(dat);
+ dat->SetContainerWindowStyle();
SendMessage(hwndDlg, WM_SIZE, 0, 0);
break;
- case CM_UPDATETITLEBAR:
- {
- HWND hwnd = (HWND)lParam;
- TitleBarData *tbd = (TitleBarData *)wParam;
- if (tbd != nullptr && dat->hwndActive == hwnd) {
- if (tbd->iFlags & TBDF_TEXT) {
- wchar_t oldtitle[256];
- GetWindowText(hwndDlg, oldtitle, _countof(oldtitle));
- if (mir_wstrcmp(tbd->pszText, oldtitle))
- SetWindowText(hwndDlg, tbd->pszText);
- }
- if (tbd->iFlags & TBDF_ICON) {
- SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)tbd->hIcon);
- if (tbd->hIconBig != nullptr)
- SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)tbd->hIconBig);
- if (pTaskbarInterface)
- pTaskbarInterface->SetOverlayIcon(hwndDlg, tbd->hIconNot, L"");
- }
- }
- }
- break;
-
- case CM_UPDATESTATUSBAR:
- {
- HWND hwnd = (HWND)lParam;
- StatusBarData *sbd = (StatusBarData *)wParam;
- if (sbd != nullptr) {
- if ((sbd->iFlags & SBDF_TEXT) && dat->hwndActive == hwnd)
- SendMessage(dat->hwndStatus, SB_SETTEXT, sbd->iItem, (LPARAM)sbd->pszText);
- if ((sbd->iFlags & SBDF_ICON) && dat->hwndActive == hwnd)
- SendMessage(dat->hwndStatus, SB_SETICON, sbd->iItem, (LPARAM)sbd->hIcon);
- RedrawWindow(dat->hwndStatus, nullptr, nullptr, RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW);
- }
- }
- break;
-
case DM_STATUSICONCHANGE:
- SendMessage(dat->hwndStatus, SB_SETTEXT, (WPARAM)(SBT_OWNERDRAW) | 2, 0);
+ SendMessage(dat->m_hwndStatus, SB_SETTEXT, (WPARAM)(SBT_OWNERDRAW) | 2, 0);
SetupStatusBar(dat);
- RedrawWindow(dat->hwndStatus, nullptr, nullptr, RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW);
- break;
-
- case CM_UPDATETABCONTROL:
- {
- TabControlData *tcd = (TabControlData*)wParam;
- int tabId = GetTabFromHWND(dat, (HWND)lParam);
- if (tabId >= 0 && tcd != nullptr) {
- wchar_t *ptszTemp = nullptr;
-
- TCITEM tci;
- tci.mask = 0;
- if (tcd->iFlags & TCDF_TEXT) {
- tci.mask |= TCIF_TEXT;
- tci.pszText = tcd->pszText;
- if (g_dat.flags2.bLimitNames) {
- wchar_t *ltext = limitText(tcd->pszText, g_dat.limitNamesLength);
- if (ltext != tcd->pszText)
- tci.pszText = ptszTemp = ltext;
- }
- }
- if (tcd->iFlags & TCDF_ICON) {
- int iconIdx = -1;
- if (tcd->hIcon != nullptr) {
- TCITEM tci2;
- tci2.mask = TCIF_IMAGE;
- TabCtrl_GetItem(dat->hwndTabs, tabId, &tci2);
- iconIdx = AddOrReplaceIcon(g_dat.hTabIconList, tci2.iImage, tcd->hIcon);
- }
- tci.mask |= TCIF_IMAGE;
- tci.iImage = iconIdx;
- }
- TabCtrl_SetItem(dat->hwndTabs, tabId, &tci);
- mir_free(ptszTemp);
- }
- }
+ RedrawWindow(dat->m_hwndStatus, nullptr, nullptr, RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW);
break;
case DM_SWITCHINFOBAR:
dat->flags2.bShowInfoBar = !dat->flags2.bShowInfoBar;
- for (int i = 0; i < dat->childrenCount; i++) {
- CMsgDialog * pDlg = GetChildFromTab(dat->hwndTabs, i);
+ for (int i = 0; i < dat->m_iChildrenCount; i++) {
+ CMsgDialog * pDlg = GetChildFromTab(dat->m_hwndTabs, i);
SendMessage(pDlg->GetHwnd(), DM_SWITCHINFOBAR, 0, 0);
}
SendMessage(hwndDlg, WM_SIZE, 0, 0);
@@ -1168,15 +1139,15 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara
case DM_SWITCHSTATUSBAR:
dat->flags2.bShowStatusBar = !dat->flags2.bShowStatusBar;
- ShowWindow(dat->hwndStatus, (dat->flags2.bShowStatusBar) ? SW_SHOW : SW_HIDE);
+ ShowWindow(dat->m_hwndStatus, (dat->flags2.bShowStatusBar) ? SW_SHOW : SW_HIDE);
SendMessage(hwndDlg, WM_SIZE, 0, 0);
break;
case DM_SWITCHTOOLBAR:
dat->flags2.bShowToolBar = !dat->flags2.bShowToolBar;
- for (int i = 0; i < dat->childrenCount; i++) {
- CMsgDialog * pDlg = GetChildFromTab(dat->hwndTabs, i);
+ for (int i = 0; i < dat->m_iChildrenCount; i++) {
+ CMsgDialog * pDlg = GetChildFromTab(dat->m_hwndTabs, i);
SendMessage(pDlg->GetHwnd(), DM_SWITCHTOOLBAR, 0, 0);
}
@@ -1337,16 +1308,16 @@ HWND GetParentWindow(MCONTACT hContact, bool bChat)
if (g_dat.flags2.bUseTabs) {
if (!bChat || !g_dat.flags2.bSeparateChats) {
if (g_dat.lastParent != nullptr) {
- int tabsNum = (int)SendMessage(g_dat.lastParent->hwnd, CM_GETCHILDCOUNT, 0, 0);
+ int tabsNum = g_dat.lastParent->GetChildCount();
if (!g_dat.flags2.bLimitTabs || tabsNum < g_dat.limitTabsNum)
- return g_dat.lastParent->hwnd;
+ return g_dat.lastParent->m_hwnd;
}
}
else {
if (g_dat.lastChatParent != nullptr) {
- int tabsNum = (int)SendMessage(g_dat.lastChatParent->hwnd, CM_GETCHILDCOUNT, 0, 0);
+ int tabsNum = g_dat.lastParent->GetChildCount();
if (!g_dat.flags2.bLimitChatTabs || tabsNum < g_dat.limitChatsTabsNum)
- return g_dat.lastChatParent->hwnd;
+ return g_dat.lastChatParent->m_hwnd;
}
}
}
diff --git a/plugins/Scriver/src/tabs.h b/plugins/Scriver/src/tabs.h
index a4068b37d7..bb2aeb7491 100644
--- a/plugins/Scriver/src/tabs.h
+++ b/plugins/Scriver/src/tabs.h
@@ -23,22 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef MSGWINDOW_H
#define MSGWINDOW_H
-/* container services */
-#define CM_ADDCHILD (WM_USER+0x180)
-#define CM_REMOVECHILD (WM_USER+0x181)
-#define CM_ACTIVATECHILD (WM_USER+0x182)
-#define CM_ACTIVATEPREV (WM_USER+0x183)
-#define CM_ACTIVATENEXT (WM_USER+0x184)
-#define CM_ACTIVATEBYINDEX (WM_USER+0x185)
-
-#define CM_GETCHILDCOUNT (WM_USER+0x188)
-
-#define CM_UPDATETITLEBAR (WM_USER+0x190)
-#define CM_UPDATESTATUSBAR (WM_USER+0x191)
-#define CM_UPDATETABCONTROL (WM_USER+0x192)
-#define CM_STARTFLASHING (WM_USER+0x1A0)
-#define CM_POPUPWINDOW (WM_USER+0x1A1)
-
/* child window services */
#define DM_UPDATETABCONTROL (WM_USER+0x1B2)
#define DM_SETPARENT (WM_USER+0x1B3)
@@ -47,17 +31,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define DM_SETFOCUS (WM_USER+0x1BA)
#define DM_CLISTSETTINGSCHANGED (WM_USER+0x1BB)
-#define SBDF_TEXT 1
-#define SBDF_ICON 2
-
-struct StatusBarData
-{
- int iItem;
- int iFlags;
- wchar_t *pszText;
- HICON hIcon;
-};
-
#define TBDF_TEXT 1
#define TBDF_ICON 2
@@ -80,6 +53,74 @@ struct TabControlData
HICON hIcon;
};
+#define SBDF_TEXT 1
+#define SBDF_ICON 2
+
+struct StatusBarData
+{
+ int iItem;
+ int iFlags;
+ wchar_t *pszText;
+ HICON hIcon;
+};
+
+struct TabCtrlData
+{
+ int lastClickTime;
+ WPARAM clickWParam;
+ LPARAM clickLParam;
+ POINT mouseLBDownPos;
+ HIMAGELIST hDragImageList;
+ int bDragging;
+ int bDragged;
+ int destTab;
+ int srcTab;
+};
+
+struct ParentWindowData
+{
+ HWND m_hwnd;
+ MCONTACT m_hContact;
+ int m_iChildrenCount;
+ HWND m_hwndActive;
+ HWND m_hwndStatus;
+ HWND m_hwndTabs;
+ TabFlags flags2;
+ RECT childRect;
+ POINT mouseLBDownPos;
+ int mouseLBDown;
+ int nFlash;
+ int nFlashMax;
+ int bMinimized;
+ int bVMaximized;
+ int iSplitterX, iSplitterY;
+
+ bool bTopmost;
+
+ void ActivateChild(HWND child);
+ void ActivateChildByIndex(int index);
+ void ActivateNextChild(HWND child);
+ void ActivatePrevChild(HWND child);
+ void AddChild(CMsgDialog *pDlg);
+ void CloseOtherChilden(CMsgDialog *pDlg);
+ int GetChildCount();
+ void GetChildWindowRect(RECT *rcChild);
+ int GetTabFromHWND(HWND child);
+ CMsgDialog *GetChildFromHWND(HWND hwnd);
+ void PopupWindow(HWND hwnd, bool bIncoming);
+ void RemoveChild(HWND child);
+ void SetContainerWindowStyle();
+ void StartFlashing();
+ void UpdateStatusBar(const StatusBarData &sbd, HWND);
+ void UpdateTabControl(const TabControlData &tbd, HWND);
+ void UpdateTitleBar(const TitleBarData &tbd, HWND);
+
+ int windowWasCascaded;
+ TabCtrlData *tabCtrlDat;
+ BOOL isChat;
+ ParentWindowData *prev, *next;
+};
+
HWND GetParentWindow(MCONTACT hContact, bool bChat);
#endif