summaryrefslogtreecommitdiff
path: root/src
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 /src
parent03445a3f1a04fcff892832b928308d37aeeea3cb (diff)
GC_CLOSEWINDOW -> CloseTab()
Diffstat (limited to 'src')
-rw-r--r--src/core/stdmsg/src/chat_options.cpp2
-rw-r--r--src/core/stdmsg/src/chat_window.cpp31
-rw-r--r--src/core/stdmsg/src/msgs.h2
-rw-r--r--src/core/stdmsg/src/stdafx.h2
-rw-r--r--src/core/stdmsg/src/tabs.cpp7
-rw-r--r--src/mir_app/src/chat_clist.cpp2
-rw-r--r--src/mir_app/src/chat_manager.cpp2
-rw-r--r--src/mir_app/src/chat_svc.cpp4
8 files changed, 32 insertions, 20 deletions
diff --git a/src/core/stdmsg/src/chat_options.cpp b/src/core/stdmsg/src/chat_options.cpp
index 9a29883a9d..13b6d7f0af 100644
--- a/src/core/stdmsg/src/chat_options.cpp
+++ b/src/core/stdmsg/src/chat_options.cpp
@@ -430,7 +430,7 @@ static INT_PTR CALLBACK DlgProcOptions1(HWND hwndDlg, UINT uMsg, WPARAM, LPARAM
g_Settings.bLogIndentEnabled = db_get_b(NULL, CHAT_MODULE, "LogIndentEnabled", 1) != 0;
if (b != db_get_b(NULL, CHAT_MODULE, "Tabs", 1)) {
- pci->SM_BroadcastMessage(NULL, GC_CLOSEWINDOW, 0, 1, FALSE);
+ pci->SM_BroadcastMessage(NULL, WM_CLOSE, 0, 1, FALSE);
g_Settings.bTabsEnable = db_get_b(NULL, CHAT_MODULE, "Tabs", 1) != 0;
}
else pci->SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE);
diff --git a/src/core/stdmsg/src/chat_window.cpp b/src/core/stdmsg/src/chat_window.cpp
index 587084f34c..7a5ba87fde 100644
--- a/src/core/stdmsg/src/chat_window.cpp
+++ b/src/core/stdmsg/src/chat_window.cpp
@@ -270,12 +270,12 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
}
if (wParam == VK_F4 && isCtrl && !isAlt) { // ctrl-F4 (close tab)
- SendMessage(hwndDlg, GC_CLOSEWINDOW, 0, 0);
+ pDlg->CloseTab();
return TRUE;
}
if (wParam == VK_ESCAPE && !isCtrl && !isAlt) { // Esc (close tab)
- SendMessage(hwndDlg, GC_CLOSEWINDOW, 0, 0);
+ pDlg->CloseTab();
return TRUE;
}
@@ -352,7 +352,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
}
if (wParam == 0x57 && isCtrl && !isAlt) { // ctrl-w (close window)
- SendMessage(hwndDlg, GC_CLOSEWINDOW, 0, 0);
+ pDlg->CloseTab();
return TRUE;
}
@@ -652,6 +652,9 @@ static LRESULT CALLBACK LogSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR
{
CHARRANGE sel;
+ HWND hwndDlg = GetParent(hwnd);
+ CChatRoomDlg *pDlg = (CChatRoomDlg*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+
switch (msg) {
case WM_LBUTTONUP:
SendMessage(hwnd, EM_EXGETSEL, 0, (LPARAM)&sel);
@@ -665,7 +668,7 @@ static LRESULT CALLBACK LogSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR
case WM_KEYDOWN:
if (wParam == 0x57 && GetKeyState(VK_CONTROL) & 0x8000) { // ctrl-w (close window)
- PostMessage(GetParent(hwnd), GC_CLOSEWINDOW, 0, 0);
+ pDlg->CloseTab();
return TRUE;
}
break;
@@ -721,7 +724,7 @@ LRESULT CALLBACK CChatRoomDlg::NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM
case WM_KEYDOWN:
if (wParam == 0x57 && GetKeyState(VK_CONTROL) & 0x8000) { // ctrl-w (close window)
- PostMessage(GetParent(hwnd), GC_CLOSEWINDOW, 0, 0);
+ si->pDlg->CloseTab();
return TRUE;
}
break;
@@ -881,6 +884,7 @@ CChatRoomDlg::CChatRoomDlg(SESSION_INFO *si) :
void CChatRoomDlg::OnInitDialog()
{
m_si->pDlg = this;
+ SetWindowLongPtr(m_hwnd, GWLP_USERDATA, LPARAM(this));
if (g_Settings.bTabsEnable)
SetWindowLongPtr(m_hwnd, GWL_EXSTYLE, GetWindowLongPtr(m_hwnd, GWL_EXSTYLE) | WS_EX_APPWINDOW);
@@ -892,12 +896,14 @@ void CChatRoomDlg::OnInitDialog()
NotifyLocalWinEvent(m_hContact, m_hwnd, MSG_WINDOW_EVT_OPENING);
- mir_subclassWindow(m_log.GetHwnd(), LogSubclassProc);
mir_subclassWindow(m_btnFilter.GetHwnd(), ButtonSubclassProc);
mir_subclassWindow(m_btnColor.GetHwnd(), ButtonSubclassProc);
mir_subclassWindow(m_btnBkColor.GetHwnd(), ButtonSubclassProc);
mir_subclassWindow(m_message.GetHwnd(), MessageSubclassProc);
+ SetWindowLongPtr(m_log.GetHwnd(), GWLP_USERDATA, LPARAM(this));
+ mir_subclassWindow(m_log.GetHwnd(), LogSubclassProc);
+
SetWindowLongPtr(m_nickList.GetHwnd(), GWLP_USERDATA, LPARAM(m_si));
mir_subclassWindow(m_nickList.GetHwnd(), NicklistSubclassProc);
@@ -1207,6 +1213,13 @@ void CChatRoomDlg::SaveWindowPosition(bool bUpdateSession)
}
}
+void CChatRoomDlg::CloseTab(bool)
+{
+ if (g_Settings.bTabsEnable)
+ SendMessage(GetParent(m_hwndParent), GC_REMOVETAB, 0, (LPARAM)this);
+ Close();
+}
+
void CChatRoomDlg::UpdateTitle()
{
wchar_t szTemp[100];
@@ -1494,12 +1507,6 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
UpdateTitle();
break;
- case GC_CLOSEWINDOW:
- if (g_Settings.bTabsEnable)
- SendMessage(GetParent(m_hwndParent), GC_REMOVETAB, 0, (LPARAM)this);
- Close();
- return 0;
-
case GC_CHANGEFILTERFLAG:
m_iLogFilterFlags = lParam;
break;
diff --git a/src/core/stdmsg/src/msgs.h b/src/core/stdmsg/src/msgs.h
index 83765176ef..60c2ef2d8f 100644
--- a/src/core/stdmsg/src/msgs.h
+++ b/src/core/stdmsg/src/msgs.h
@@ -98,6 +98,8 @@ public:
virtual void OnDestroy() override;
virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
+
+ virtual void CloseTab(bool) override {}
virtual void UpdateTitle() override {}
void OnSplitterMoved(CSplitter*);
diff --git a/src/core/stdmsg/src/stdafx.h b/src/core/stdmsg/src/stdafx.h
index 897a1bb93e..758dd5a612 100644
--- a/src/core/stdmsg/src/stdafx.h
+++ b/src/core/stdmsg/src/stdafx.h
@@ -204,6 +204,8 @@ public:
virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
virtual int Resizer(UTILRESIZECONTROL *urc) override;
+
+ virtual void CloseTab(bool bForced = false) override;
virtual void UpdateTitle() override;
void OnClick_Bold(CCtrlButton*);
diff --git a/src/core/stdmsg/src/tabs.cpp b/src/core/stdmsg/src/tabs.cpp
index bcb691f467..40357f92eb 100644
--- a/src/core/stdmsg/src/tabs.cpp
+++ b/src/core/stdmsg/src/tabs.cpp
@@ -147,8 +147,11 @@ static LRESULT CALLBACK TabSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR
ScreenToClient(hwnd, &tci.pt);
int i = TabCtrl_HitTest(hwnd, &tci);
- if (i != -1 && g_Settings.bTabCloseOnDblClick)
- PostMessage(GetParent(hwnd), GC_CLOSEWINDOW, 0, 0);
+ if (i != -1 && g_Settings.bTabCloseOnDblClick) {
+ CSrmmBaseDialog *pDlg = (CSrmmBaseDialog*)pOwner->m_tab.GetActivePage();
+ if (pDlg)
+ pDlg->CloseTab();
+ }
}
break;
diff --git a/src/mir_app/src/chat_clist.cpp b/src/mir_app/src/chat_clist.cpp
index c197c92f33..43b6c7791a 100644
--- a/src/mir_app/src/chat_clist.cpp
+++ b/src/mir_app/src/chat_clist.cpp
@@ -118,7 +118,7 @@ int RoomDoubleclicked(WPARAM hContact, LPARAM)
if (si) {
// is the "toggle visibility option set, so we need to close the window?
if (si->pDlg != nullptr && db_get_b(0, CHAT_MODULE, "ToggleVisibility", 0) == 1 && !cli.pfnGetEvent(hContact, 0) && IsWindowVisible(si->pDlg->GetHwnd()) && !IsIconic(si->pDlg->GetHwnd())) {
- PostMessage(si->pDlg->GetHwnd(), GC_CLOSEWINDOW, 0, 0);
+ si->pDlg->CloseTab();
return 1;
}
chatApi.ShowRoom(si);
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp
index b3ffd8fe09..d8cfe40999 100644
--- a/src/mir_app/src/chat_manager.cpp
+++ b/src/mir_app/src/chat_manager.cpp
@@ -73,7 +73,7 @@ static void SM_FreeSession(SESSION_INFO *si, bool bRemoveContact = false)
db_set_w(si->hContact, si->pszModule, "ApparentMode", 0);
if (si->pDlg)
- SendMessage(si->pDlg->GetHwnd(), GC_CLOSEWINDOW, 0, 1);
+ si->pDlg->CloseTab(true);
DoEventHook(si, GC_SESSION_TERMINATE, nullptr, nullptr, (INT_PTR)si->pItemData);
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp
index 2becb12910..d7ac64cd01 100644
--- a/src/mir_app/src/chat_svc.cpp
+++ b/src/mir_app/src/chat_svc.cpp
@@ -102,8 +102,6 @@ static int IconsChanged(WPARAM, LPARAM)
static int PreShutdown(WPARAM, LPARAM)
{
if (g_Settings != nullptr) {
- chatApi.SM_BroadcastMessage(nullptr, GC_CLOSEWINDOW, 0, 1, FALSE);
-
SM_RemoveAll();
chatApi.MM_RemoveAll();
@@ -284,7 +282,7 @@ static INT_PTR __stdcall stubRoomControl(void *param)
SetInitDone(si);
chatApi.SetActiveSession(si);
if (si->pDlg)
- ::SendMessage(si->pDlg->GetHwnd(), GC_CLOSEWINDOW, 0, 0);
+ si->pDlg->CloseTab();
break;
case WINDOW_VISIBLE: