summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2016-12-16 16:16:21 +0300
committerGeorge Hazan <ghazan@miranda.im>2016-12-16 16:16:21 +0300
commiteaf0435f78ea8c0317e7f2628176c2325e95b022 (patch)
tree8a676a7e0d0fd97491c74aef9cc5da017ceff6c5 /src
parent4a3fcb3dbc6b928415d7b5500b4d32b795b86602 (diff)
- GC_SAVEWNDPOS removed and replaced with class member;
- TabCtrl_* functions replaced with CCtrlPages members
Diffstat (limited to 'src')
-rw-r--r--src/core/stdmsg/src/chat_window.cpp51
-rw-r--r--src/core/stdmsg/src/stdafx.h1
-rw-r--r--src/core/stdmsg/src/tabs.cpp40
3 files changed, 44 insertions, 48 deletions
diff --git a/src/core/stdmsg/src/chat_window.cpp b/src/core/stdmsg/src/chat_window.cpp
index 75bba991a2..cc13f1e28d 100644
--- a/src/core/stdmsg/src/chat_window.cpp
+++ b/src/core/stdmsg/src/chat_window.cpp
@@ -216,7 +216,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
if (wParam == VK_TAB && isCtrl && !isShift) { // CTRL-TAB (switch tab/window)
if (g_Settings.bTabsEnable)
- SendMessage(hwndDlg, GC_SWITCHNEXTTAB, 0, 0);
+ SendMessage(GetParent(GetParent(hwndDlg)), GC_SWITCHNEXTTAB, 0, 0);
else
pci->ShowRoom(SM_GetNextWindow(dat->si), WINDOW_VISIBLE, TRUE);
return TRUE;
@@ -224,7 +224,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
if (wParam == VK_TAB && isCtrl && isShift) { // CTRL_SHIFT-TAB (switch tab/window)
if (g_Settings.bTabsEnable)
- SendMessage(hwndDlg, GC_SWITCHPREVTAB, 0, 0);
+ SendMessage(GetParent(GetParent(hwndDlg)), GC_SWITCHPREVTAB, 0, 0);
else
pci->ShowRoom(SM_GetPrevWindow(dat->si), WINDOW_VISIBLE, TRUE);
return TRUE;
@@ -946,7 +946,7 @@ void CChatRoomDlg::OnInitDialog()
void CChatRoomDlg::OnDestroy()
{
NotifyLocalWinEvent(m_si->hContact, m_hwnd, MSG_WINDOW_EVT_CLOSING);
- SendMessage(m_hwnd, GC_SAVEWNDPOS, 0, 0);
+ SaveWindowPosition(true);
m_si->pDlg = NULL;
m_si->hWnd = NULL;
@@ -1167,6 +1167,25 @@ void CChatRoomDlg::SetWindowPosition()
}
}
+void CChatRoomDlg::SaveWindowPosition(bool bUpdateSession)
+{
+ WINDOWPLACEMENT wp = { 0 };
+ wp.length = sizeof(wp);
+ GetWindowPlacement(getCaptionWindow(), &wp);
+
+ g_Settings.iX = wp.rcNormalPosition.left;
+ g_Settings.iY = wp.rcNormalPosition.top;
+ g_Settings.iWidth = wp.rcNormalPosition.right - wp.rcNormalPosition.left;
+ g_Settings.iHeight = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top;
+
+ if (bUpdateSession) {
+ m_si->iX = g_Settings.iX;
+ m_si->iY = g_Settings.iY;
+ m_si->iWidth = g_Settings.iWidth;
+ m_si->iHeight = g_Settings.iHeight;
+ }
+}
+
INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
SESSION_INFO *s;
@@ -1275,26 +1294,6 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
}
return TRUE;
- case GC_SAVEWNDPOS:
- {
- WINDOWPLACEMENT wp = { 0 };
- wp.length = sizeof(wp);
- GetWindowPlacement(getCaptionWindow(), &wp);
-
- g_Settings.iX = wp.rcNormalPosition.left;
- g_Settings.iY = wp.rcNormalPosition.top;
- g_Settings.iWidth = wp.rcNormalPosition.right - wp.rcNormalPosition.left;
- g_Settings.iHeight = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top;
-
- if (!lParam) {
- m_si->iX = g_Settings.iX;
- m_si->iY = g_Settings.iY;
- m_si->iWidth = g_Settings.iWidth;
- m_si->iHeight = g_Settings.iHeight;
- }
- }
- break;
-
case WM_SIZE:
if (wParam == SIZE_MAXIMIZED)
PostMessage(m_hwnd, GC_SCROLLTOBOTTOM, 0, 0);
@@ -1342,7 +1341,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
InvalidateRect(m_si->hwndStatus, NULL, TRUE);
RedrawWindow(m_message.GetHwnd(), NULL, NULL, RDW_INVALIDATE);
RedrawWindow(m_btnOk.GetHwnd(), NULL, NULL, RDW_INVALIDATE);
- SendMessage(m_hwnd, GC_SAVEWNDPOS, 0, 1);
+ SaveWindowPosition(false);
}
return TRUE;
@@ -1486,7 +1485,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
case SESSION_TERMINATE:
if (!g_Settings.bTabsEnable) {
- SendMessage(m_hwnd, GC_SAVEWNDPOS, 0, 0);
+ SaveWindowPosition(true);
if (db_get_b(NULL, CHAT_MODULE, "SavePosition", 0)) {
db_set_dw(m_si->hContact, CHAT_MODULE, "roomx", m_si->iX);
db_set_dw(m_si->hContact, CHAT_MODULE, "roomy", m_si->iY);
@@ -1850,7 +1849,7 @@ LABEL_SHOWWINDOW:
break;
case WM_MOVE:
- SendMessage(m_hwnd, GC_SAVEWNDPOS, 0, 1);
+ SaveWindowPosition(false);
break;
case WM_GETMINMAXINFO:
diff --git a/src/core/stdmsg/src/stdafx.h b/src/core/stdmsg/src/stdafx.h
index 2b0f23a72c..67baab68f7 100644
--- a/src/core/stdmsg/src/stdafx.h
+++ b/src/core/stdmsg/src/stdafx.h
@@ -187,6 +187,7 @@ class CChatRoomDlg : public CDlgBase
{ return (g_Settings.bTabsEnable) ? GetParent(m_hwndParent) : m_hwnd;
}
+ void SaveWindowPosition(bool bUpdateSession);
void SetWindowPosition();
public:
diff --git a/src/core/stdmsg/src/tabs.cpp b/src/core/stdmsg/src/tabs.cpp
index 288ba61d18..520e778913 100644
--- a/src/core/stdmsg/src/tabs.cpp
+++ b/src/core/stdmsg/src/tabs.cpp
@@ -222,7 +222,7 @@ void CTabbedWindow::AddPage(SESSION_INFO *si, int insertAt)
TCITEM tci;
tci.mask = TCIF_PARAM;
- int tabCount = TabCtrl_GetItemCount(m_tab.GetHwnd());
+ int tabCount = m_tab.GetCount();
// does the tab already exist?
for (int i = 0; i < tabCount; i++) {
@@ -323,14 +323,14 @@ INT_PTR CTabbedWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
case GC_SWITCHNEXTTAB:
{
- int total = TabCtrl_GetItemCount(m_tab.GetHwnd());
+ int total = m_tab.GetCount();
int i = TabCtrl_GetCurSel(m_tab.GetHwnd());
- if (i != -1 && total != -1 && total != 1) {
+ if (i != -1 && total > 1) {
if (i < total - 1)
i++;
else
i = 0;
- TabCtrl_SetCurSel(m_tab.GetHwnd(), i);
+ m_tab.ActivatePage(i);
TabClicked();
}
}
@@ -338,14 +338,14 @@ INT_PTR CTabbedWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
case GC_SWITCHPREVTAB:
{
- int total = TabCtrl_GetItemCount(m_tab.GetHwnd());
+ int total = m_tab.GetCount();
int i = TabCtrl_GetCurSel(m_tab.GetHwnd());
- if (i != -1 && total != -1 && total != 1) {
+ if (i != -1 && total >= 1) {
if (i > 0)
i--;
else
i = total - 1;
- TabCtrl_SetCurSel(m_tab.GetHwnd(), i);
+ m_tab.ActivatePage(i);
TabClicked();
}
}
@@ -353,10 +353,10 @@ INT_PTR CTabbedWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
case GC_SWITCHTAB:
{
- int total = TabCtrl_GetItemCount(m_tab.GetHwnd());
+ int total = m_tab.GetCount();
int i = TabCtrl_GetCurSel(m_tab.GetHwnd());
if (i != -1 && total != -1 && total != 1 && i != lParam && total > lParam) {
- TabCtrl_SetCurSel(m_tab.GetHwnd(), lParam);
+ m_tab.ActivatePage(i);
TabClicked();
}
}
@@ -365,7 +365,7 @@ INT_PTR CTabbedWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
case GC_REMOVETAB:
{
int i = -1;
- int tabCount = TabCtrl_GetItemCount(m_tab.GetHwnd());
+ int tabCount = m_tab.GetCount();
if (lParam) {
for (i = 0; i < tabCount; i++) {
TCITEM tci = {};
@@ -378,7 +378,7 @@ INT_PTR CTabbedWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
else i = TabCtrl_GetCurSel(m_tab.GetHwnd());
if (i != -1 && i < tabCount) {
- TabCtrl_DeleteItem(m_tab.GetHwnd(), i);
+ m_tab.RemovePage(i);
TCITEM id = {};
id.mask = TCIF_PARAM;
@@ -439,12 +439,11 @@ INT_PTR CTabbedWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
TabCtrl_GetItem(m_tab.GetHwnd(), begin, &tci);
SESSION_INFO *s = (SESSION_INFO*)tci.lParam;
if (s) {
- TabCtrl_DeleteItem(m_tab.GetHwnd(), begin);
-
- SendMessage(m_hwnd, GC_ADDTAB, end, (LPARAM)s);
+ m_tab.RemovePage(begin);
+ AddPage(s);
// fix the "fixed" positions
- int tabCount = TabCtrl_GetItemCount(m_tab.GetHwnd());
+ int tabCount = m_tab.GetCount();
for (int i = 0; i < tabCount; i++) {
TabCtrl_GetItem(m_tab.GetHwnd(), i, &tci);
s = (SESSION_INFO*)tci.lParam;
@@ -510,23 +509,20 @@ INT_PTR CTabbedWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
if (TabCtrl_GetCurSel(GetDlgItem(m_hwnd, IDC_TAB)) == i)
PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDCANCEL, BN_CLICKED), 0);
else
- TabCtrl_DeleteItem(GetDlgItem(m_hwnd, IDC_TAB), i);
+ m_tab.RemovePage(i);
break;
case ID_CLOSEOTHER:
{
- int tabCount = TabCtrl_GetItemCount(GetDlgItem(m_hwnd, IDC_TAB)) - 1;
+ int tabCount = m_tab.GetCount()-1;
if (tabCount > 0) {
- if (TabCtrl_GetCurSel(GetDlgItem(m_hwnd, IDC_TAB)) != i)
- if (s)
- pci->ShowRoom(s, WINDOW_VISIBLE, TRUE);
-
for (tabCount; tabCount >= 0; tabCount--) {
if (tabCount == i)
continue;
- TabCtrl_DeleteItem(GetDlgItem(m_hwnd, IDC_TAB), tabCount);
+ m_tab.RemovePage(tabCount);
}
+ m_tab.ActivatePage(0);
}
}
break;