summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-03-11 16:33:16 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-03-11 16:33:16 +0300
commit2b419ed6e80f65138a198f32a3ffe85bf39a5fcb (patch)
treedbae4aba940cebfffb67d79d9b27501f20476b98 /plugins/TabSRMM
parent03445a3f1a04fcff892832b928308d37aeeea3cb (diff)
GC_CLOSEWINDOW -> CloseTab()
Diffstat (limited to 'plugins/TabSRMM')
-rw-r--r--plugins/TabSRMM/src/chat_window.cpp94
-rw-r--r--plugins/TabSRMM/src/msgs.h4
2 files changed, 50 insertions, 48 deletions
diff --git a/plugins/TabSRMM/src/chat_window.cpp b/plugins/TabSRMM/src/chat_window.cpp
index 219613964d..d688d2ca85 100644
--- a/plugins/TabSRMM/src/chat_window.cpp
+++ b/plugins/TabSRMM/src/chat_window.cpp
@@ -595,7 +595,7 @@ LRESULT CALLBACK CChatRoomDlg::MessageSubclassProc(HWND hwnd, UINT msg, WPARAM w
bool isShift, isAlt, isCtrl;
mwdat->KbdState(isShift, isCtrl, isAlt);
- if (PluginConfig.m_bSoundOnTyping && !isAlt &&!isCtrl&&!(mwdat->m_pContainer->dwFlags & CNT_NOSOUND) && wParam != VK_ESCAPE&&!(wParam == VK_TAB && PluginConfig.m_bAllowTab))
+ if (PluginConfig.m_bSoundOnTyping && !isAlt && !isCtrl && !(mwdat->m_pContainer->dwFlags & CNT_NOSOUND) && wParam != VK_ESCAPE && !(wParam == VK_TAB && PluginConfig.m_bAllowTab))
SkinPlaySound("SoundOnTyping");
if (isCtrl && !isAlt && !isShift) {
@@ -1950,6 +1950,50 @@ void CChatRoomDlg::onDblClick_List(CCtrlListBox*)
/////////////////////////////////////////////////////////////////////////////////////////
+void CChatRoomDlg::CloseTab(bool bForced)
+{
+ int iTabs = TabCtrl_GetItemCount(m_hwndParent);
+ if (iTabs == 1 && CMimAPI::m_shutDown == 0) {
+ SendMessage(m_pContainer->hwnd, WM_CLOSE, 0, 1);
+ return;
+ }
+
+ m_pContainer->iChilds--;
+ int i = GetTabIndexFromHWND(m_hwndParent, m_hwnd);
+
+ // after closing a tab, we need to activate the tab to the left side of
+ // the previously open tab.
+ // normally, this tab has the same index after the deletion of the formerly active tab
+ // unless, of course, we closed the last (rightmost) tab.
+ if (!m_pContainer->bDontSmartClose && iTabs > 1 && !bForced) {
+ if (i == iTabs - 1)
+ i--;
+ else
+ i++;
+ TabCtrl_SetCurSel(m_hwndParent, i);
+
+ TCITEM item = {};
+ item.mask = TCIF_PARAM;
+ TabCtrl_GetItem(m_hwndParent, i, &item); // retrieve dialog hwnd for the now active tab...
+ m_pContainer->hwndActive = (HWND)item.lParam;
+
+ RECT rc;
+ SendMessage(m_pContainer->hwnd, DM_QUERYCLIENTAREA, 0, (LPARAM)&rc);
+ SetWindowPos(m_pContainer->hwndActive, HWND_TOP, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), SWP_SHOWWINDOW);
+ ShowWindow((HWND)item.lParam, SW_SHOW);
+ SetForegroundWindow(m_pContainer->hwndActive);
+ SetFocus(m_pContainer->hwndActive);
+ SendMessage(m_pContainer->hwnd, WM_SIZE, 0, 0);
+ }
+
+ if (iTabs == 1)
+ SendMessage(m_pContainer->hwnd, WM_CLOSE, 0, 1);
+ else {
+ PostMessage(m_pContainer->hwnd, WM_SIZE, 0, 0);
+ DestroyWindow(m_hwnd);
+ }
+}
+
void CChatRoomDlg::UpdateTitle()
{
m_wStatus = m_si->wStatus;
@@ -2915,53 +2959,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
}
_dlgReturn(m_hwnd, TRUE);
}
- SendMessage(m_hwnd, GC_CLOSEWINDOW, 0, 1);
- return 0;
-
- case GC_CLOSEWINDOW:
- {
- bool bForced = (lParam == 2);
-
- int iTabs = TabCtrl_GetItemCount(m_hwndParent);
- if (iTabs == 1 && CMimAPI::m_shutDown == 0) {
- SendMessage(m_pContainer->hwnd, WM_CLOSE, 0, 1);
- return 1;
- }
-
- m_pContainer->iChilds--;
- int i = GetTabIndexFromHWND(m_hwndParent, m_hwnd);
-
- // after closing a tab, we need to activate the tab to the left side of
- // the previously open tab.
- // normally, this tab has the same index after the deletion of the formerly active tab
- // unless, of course, we closed the last (rightmost) tab.
- if (!m_pContainer->bDontSmartClose && iTabs > 1 && !bForced) {
- if (i == iTabs - 1)
- i--;
- else
- i++;
- TabCtrl_SetCurSel(m_hwndParent, i);
-
- TCITEM item = {};
- item.mask = TCIF_PARAM;
- TabCtrl_GetItem(m_hwndParent, i, &item); // retrieve dialog hwnd for the now active tab...
- m_pContainer->hwndActive = (HWND)item.lParam;
-
- SendMessage(m_pContainer->hwnd, DM_QUERYCLIENTAREA, 0, (LPARAM)&rc);
- SetWindowPos(m_pContainer->hwndActive, HWND_TOP, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), SWP_SHOWWINDOW);
- ShowWindow((HWND)item.lParam, SW_SHOW);
- SetForegroundWindow(m_pContainer->hwndActive);
- SetFocus(m_pContainer->hwndActive);
- SendMessage(m_pContainer->hwnd, WM_SIZE, 0, 0);
- }
-
- if (iTabs == 1)
- SendMessage(m_pContainer->hwnd, WM_CLOSE, 0, 1);
- else {
- PostMessage(m_pContainer->hwnd, WM_SIZE, 0, 0);
- DestroyWindow(m_hwnd);
- }
- }
+ CloseTab(true);
return 0;
case DM_SAVESIZE:
diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h
index a2777ce4aa..7dc383a505 100644
--- a/plugins/TabSRMM/src/msgs.h
+++ b/plugins/TabSRMM/src/msgs.h
@@ -455,6 +455,8 @@ public:
virtual void OnDestroy() override;
virtual int Resizer(UTILRESIZECONTROL *urc) override;
+
+ virtual void CloseTab(bool) override {};
virtual void UpdateTitle() override;
virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
@@ -496,6 +498,8 @@ public:
virtual void OnDestroy() override;
virtual int Resizer(UTILRESIZECONTROL *urc) override;
+
+ virtual void CloseTab(bool bForced = false) override;
virtual void UpdateTitle() override;
virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;