diff options
author | George Hazan <ghazan@miranda.im> | 2016-12-16 18:42:52 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2016-12-16 18:42:52 +0300 |
commit | e2c43ebb133f186e8aff5f05a4e97929ea185842 (patch) | |
tree | 2827f18e72502e2f8d56d402501703ebbd9fbaf8 /src | |
parent | ea5f8b9d8dea03c3ed6dc7c56528f10c39d39f93 (diff) |
fix for closing tabs
Diffstat (limited to 'src')
-rw-r--r-- | src/core/stdmsg/src/chat_manager.cpp | 2 | ||||
-rw-r--r-- | src/core/stdmsg/src/chat_window.cpp | 18 | ||||
-rw-r--r-- | src/core/stdmsg/src/stdafx.h | 5 | ||||
-rw-r--r-- | src/core/stdmsg/src/tabs.cpp | 54 |
4 files changed, 27 insertions, 52 deletions
diff --git a/src/core/stdmsg/src/chat_manager.cpp b/src/core/stdmsg/src/chat_manager.cpp index 906e4988c7..b1f45c943e 100644 --- a/src/core/stdmsg/src/chat_manager.cpp +++ b/src/core/stdmsg/src/chat_manager.cpp @@ -96,7 +96,7 @@ static void OnCreateModule(MODULEINFO *mi) static void OnDblClickSession(SESSION_INFO *si) { if (g_Settings.bTabsEnable) - SendMessage(si->hWnd, GC_REMOVETAB, 1, (LPARAM)si); + SendMessage(GetParent(GetParent(si->hWnd)), GC_REMOVETAB, 0, (LPARAM)si->pDlg); else PostMessage(si->hWnd, GC_CLOSEWINDOW, 0, 0); } diff --git a/src/core/stdmsg/src/chat_window.cpp b/src/core/stdmsg/src/chat_window.cpp index 928569ed29..155fc9e75b 100644 --- a/src/core/stdmsg/src/chat_window.cpp +++ b/src/core/stdmsg/src/chat_window.cpp @@ -301,7 +301,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, } if (wParam == VK_F4 && isCtrl && !isAlt) { // ctrl-F4 (close tab) - SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDCANCEL, BN_CLICKED), 0); + SendMessage(hwndDlg, GC_CLOSEWINDOW, 0, 0); return TRUE; } @@ -860,7 +860,6 @@ CChatRoomDlg::CChatRoomDlg(SESSION_INFO *si) : m_log(this, IDC_LOG), m_btnOk(this, IDOK), - m_btnCancel(this, IDCANCEL), m_btnBold(this, IDC_BOLD), m_btnItalic(this, IDC_ITALICS), @@ -874,7 +873,7 @@ CChatRoomDlg::CChatRoomDlg(SESSION_INFO *si) : m_btnNickList(this, IDC_SHOWNICKLIST), m_btnChannelMgr(this, IDC_CHANMGR) { - m_autoClose = CLOSE_ON_CANCEL; + m_autoClose = 0; m_btnBold.OnClick = Callback(this, &CChatRoomDlg::OnClick_Bold); m_btnItalic.OnClick = Callback(this, &CChatRoomDlg::OnClick_Bold); @@ -884,7 +883,6 @@ CChatRoomDlg::CChatRoomDlg(SESSION_INFO *si) : m_btnBkColor.OnClick = Callback(this, &CChatRoomDlg::OnClick_BkColor); m_btnOk.OnClick = Callback(this, &CChatRoomDlg::OnClick_Ok); - m_btnCancel.OnClick = Callback(this, &CChatRoomDlg::OnClick_Cancel); m_btnFilter.OnClick = Callback(this, &CChatRoomDlg::OnClick_Filter); m_btnHistory.OnClick = Callback(this, &CChatRoomDlg::OnClick_History); @@ -948,6 +946,9 @@ void CChatRoomDlg::OnDestroy() NotifyLocalWinEvent(m_si->hContact, m_hwnd, MSG_WINDOW_EVT_CLOSING); SaveWindowPosition(true); + if (g_Settings.bTabsEnable) + SendMessage(GetParent(m_hwndParent), GC_REMOVETAB, 0, (LPARAM)this); + m_si->pDlg = NULL; m_si->hWnd = NULL; m_si->wState &= ~STATE_TALK; @@ -1064,11 +1065,6 @@ void CChatRoomDlg::OnClick_Options(CCtrlButton *pButton) pci->DoEventHookAsync(m_hwnd, m_si->ptszID, m_si->pszModule, GC_USER_CHANMGR, NULL, NULL, 0); } -void CChatRoomDlg::OnClick_Cancel(CCtrlButton*) -{ - SendMessage(m_hwndParent, GC_REMOVETAB, 0, 0); -} - void CChatRoomDlg::OnClick_Ok(CCtrlButton *pButton) { if (!pButton->Enabled()) @@ -1588,6 +1584,10 @@ LABEL_SHOWWINDOW: } break; + case GC_CLOSEWINDOW: + Close(); + break; + case GC_CHANGEFILTERFLAG: m_si->iLogFilterFlags = lParam; break; diff --git a/src/core/stdmsg/src/stdafx.h b/src/core/stdmsg/src/stdafx.h index 67baab68f7..09d77d8a83 100644 --- a/src/core/stdmsg/src/stdafx.h +++ b/src/core/stdmsg/src/stdafx.h @@ -173,13 +173,13 @@ void TB_SaveSession(SESSION_INFO *si); class CChatRoomDlg : public CDlgBase
{
- friend class CTabbedWindow;
+ friend struct CTabbedWindow;
SESSION_INFO *m_si;
CCtrlEdit m_message, m_log;
CCtrlListBox m_nickList;
- CCtrlButton m_btnOk, m_btnCancel;
+ CCtrlButton m_btnOk;
CCtrlButton m_btnFilter, m_btnChannelMgr, m_btnNickList, m_btnHistory;
CCtrlButton m_btnBold, m_btnItalic, m_btnUnderline, m_btnColor, m_btnBkColor;
@@ -203,7 +203,6 @@ public: void OnClick_BkColor(CCtrlButton*);
void OnClick_Ok(CCtrlButton*);
- void OnClick_Cancel(CCtrlButton*);
void OnClick_Filter(CCtrlButton*);
void OnClick_History(CCtrlButton*);
diff --git a/src/core/stdmsg/src/tabs.cpp b/src/core/stdmsg/src/tabs.cpp index 53a6c6972a..f037e7132e 100644 --- a/src/core/stdmsg/src/tabs.cpp +++ b/src/core/stdmsg/src/tabs.cpp @@ -42,11 +42,10 @@ void TB_SaveSession(SESSION_INFO *si) ///////////////////////////////////////////////////////////////////////////////////////// -class CTabbedWindow : public CDlgBase +struct CTabbedWindow : public CDlgBase { CCtrlPages m_tab; -public: CTabbedWindow() : CDlgBase(g_hInst, IDD_CONTAINER), m_tab(this, IDC_TAB) @@ -157,7 +156,7 @@ 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), WM_COMMAND, MAKEWPARAM(IDCANCEL, BN_CLICKED), 0); + PostMessage(GetParent(hwnd), GC_CLOSEWINDOW, 0, 0); } break; @@ -169,14 +168,8 @@ static LRESULT CALLBACK TabSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR ScreenToClient(hwnd, &tci.pt); int i = TabCtrl_HitTest(hwnd, &tci); - if (i != -1) { - TCITEM tc; - tc.mask = TCIF_PARAM; - TabCtrl_GetItem(hwnd, i, &tc); - SESSION_INFO *si = (SESSION_INFO*)tc.lParam; - if (si) - SendMessage(GetParent(hwnd), GC_REMOVETAB, 1, (LPARAM)si); - } + if (i != -1) + SendMessage(GetParent(hwnd), GC_REMOVETAB, 0, (LPARAM)pOwner->m_tab.GetNthPage(i)); break; } @@ -364,34 +357,17 @@ INT_PTR CTabbedWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) case GC_REMOVETAB: { - int i = -1; - int tabCount = m_tab.GetCount(); - if (lParam) { - for (i = 0; i < tabCount; i++) { - TCITEM tci = {}; - tci.mask = TCIF_PARAM; - TabCtrl_GetItem(m_tab.GetHwnd(), i, &tci); - if (lParam == tci.lParam) - break; - } - } - else i = TabCtrl_GetCurSel(m_tab.GetHwnd()); - - if (i != -1 && i < tabCount) { - m_tab.RemovePage(i); - - TCITEM id = {}; - id.mask = TCIF_PARAM; - if (!TabCtrl_GetItem(m_tab.GetHwnd(), i, &id)) { - if (!TabCtrl_GetItem(m_tab.GetHwnd(), i - 1, &id)) { - SendMessage(m_hwnd, WM_CLOSE, 0, 0); - break; - } - } + int idx = (lParam) ? m_tab.GetDlgIndex((CDlgBase*)lParam) : TabCtrl_GetCurSel(m_tab.GetHwnd()); + if (idx == -1) + break; - SESSION_INFO *s = (SESSION_INFO*)id.lParam; - if (s) - pci->ShowRoom(s, WINDOW_VISIBLE, wParam == 1 ? FALSE : TRUE); + m_tab.RemovePage(idx); + if (m_tab.GetCount() == 0) + PostMessage(m_hwnd, WM_CLOSE, 0, 0); + else { + if (m_tab.GetNthPage(idx) == NULL) + idx--; + m_tab.ActivatePage(idx); } } break; @@ -507,7 +483,7 @@ INT_PTR CTabbedWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, tci.pt.x, tci.pt.y, 0, m_hwnd, NULL)) { case ID_CLOSE: if (TabCtrl_GetCurSel(GetDlgItem(m_hwnd, IDC_TAB)) == i) - PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDCANCEL, BN_CLICKED), 0); + PostMessage(m_hwnd, GC_CLOSEWINDOW, 0, 0); else m_tab.RemovePage(i); break; |