diff options
author | George Hazan <ghazan@miranda.im> | 2017-03-18 21:10:48 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-03-18 22:06:24 +0300 |
commit | b7cd9afaf2720ac058da19c6398f40f894ba1b88 (patch) | |
tree | d19ddb8587ea9c37d53dcd4629467b046998f87a /src/core | |
parent | 0e3fdc5fc5341f4c55328f6a8a30585dcae6b3d2 (diff) |
StdMsg:
- added reaction to TCN_SELCHANGE;
- more effective way of controlling tab switch
- useless field removed from TPageInfo;
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/stdmsg/src/tabs.cpp | 104 |
1 files changed, 54 insertions, 50 deletions
diff --git a/src/core/stdmsg/src/tabs.cpp b/src/core/stdmsg/src/tabs.cpp index a3564cccb5..d8d2b5bdd5 100644 --- a/src/core/stdmsg/src/tabs.cpp +++ b/src/core/stdmsg/src/tabs.cpp @@ -399,61 +399,68 @@ INT_PTR CTabbedWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) break; case WM_NOTIFY: - if (((LPNMHDR)lParam)->idFrom == IDC_TAB && ((LPNMHDR)lParam)->code == NM_RCLICK) { - int i = TabCtrl_GetCurSel(((LPNMHDR)lParam)->hwndFrom); - if (i == -1) + if (((LPNMHDR)lParam)->idFrom == IDC_TAB) { + switch (((LPNMHDR)lParam)->code) { + case TCN_SELCHANGE: + m_tab.ActivatePage(TabCtrl_GetCurSel(m_tab.GetHwnd())); break; - TCHITTESTINFO tci = {}; - tci.pt.x = (short)LOWORD(GetMessagePos()); - tci.pt.y = (short)HIWORD(GetMessagePos()); - tci.flags = TCHT_ONITEM; - ScreenToClient(GetDlgItem(m_hwnd, IDC_TAB), &tci.pt); - if ((i = TabCtrl_HitTest(((LPNMHDR)lParam)->hwndFrom, &tci)) == -1) - break; - - SESSION_INFO *si = ((CChatRoomDlg*)m_tab.GetNthPage(i))->m_si; - - ClientToScreen(GetDlgItem(m_hwnd, IDC_TAB), &tci.pt); - HMENU hSubMenu = GetSubMenu(g_hMenu, 3); - TranslateMenu(hSubMenu); - - if (si) { - WORD w = db_get_w(si->hContact, si->pszModule, "TabPosition", 0); - if (w == 0) - CheckMenuItem(hSubMenu, ID_LOCKPOSITION, MF_BYCOMMAND | MF_UNCHECKED); - else - CheckMenuItem(hSubMenu, ID_LOCKPOSITION, MF_BYCOMMAND | MF_CHECKED); - } - else CheckMenuItem(hSubMenu, ID_LOCKPOSITION, MF_BYCOMMAND | MF_UNCHECKED); + case NM_RCLICK: + int i = TabCtrl_GetCurSel(((LPNMHDR)lParam)->hwndFrom); + if (i == -1) + break; - switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, tci.pt.x, tci.pt.y, 0, m_hwnd, NULL)) { - case ID_CLOSE: - SendMessage(m_hwnd, GC_REMOVETAB, 0, (LPARAM)m_tab.GetNthPage(i)); - break; - - case ID_LOCKPOSITION: - if (si != 0) { - if (!(GetMenuState(hSubMenu, ID_LOCKPOSITION, MF_BYCOMMAND)&MF_CHECKED)) { - if (si->hContact) - db_set_w(si->hContact, si->pszModule, "TabPosition", (WORD)(i + 1)); - } - else db_unset(si->hContact, si->pszModule, "TabPosition"); + TCHITTESTINFO tci = {}; + tci.pt.x = (short)LOWORD(GetMessagePos()); + tci.pt.y = (short)HIWORD(GetMessagePos()); + tci.flags = TCHT_ONITEM; + ScreenToClient(GetDlgItem(m_hwnd, IDC_TAB), &tci.pt); + if ((i = TabCtrl_HitTest(((LPNMHDR)lParam)->hwndFrom, &tci)) == -1) + break; + + SESSION_INFO *si = ((CChatRoomDlg*)m_tab.GetNthPage(i))->m_si; + + ClientToScreen(GetDlgItem(m_hwnd, IDC_TAB), &tci.pt); + HMENU hSubMenu = GetSubMenu(g_hMenu, 3); + TranslateMenu(hSubMenu); + + if (si) { + WORD w = db_get_w(si->hContact, si->pszModule, "TabPosition", 0); + if (w == 0) + CheckMenuItem(hSubMenu, ID_LOCKPOSITION, MF_BYCOMMAND | MF_UNCHECKED); + else + CheckMenuItem(hSubMenu, ID_LOCKPOSITION, MF_BYCOMMAND | MF_CHECKED); } - break; + else CheckMenuItem(hSubMenu, ID_LOCKPOSITION, MF_BYCOMMAND | MF_UNCHECKED); + + switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, tci.pt.x, tci.pt.y, 0, m_hwnd, NULL)) { + case ID_CLOSE: + SendMessage(m_hwnd, GC_REMOVETAB, 0, (LPARAM)m_tab.GetNthPage(i)); + break; + + case ID_LOCKPOSITION: + if (si != 0) { + if (!(GetMenuState(hSubMenu, ID_LOCKPOSITION, MF_BYCOMMAND)&MF_CHECKED)) { + if (si->hContact) + db_set_w(si->hContact, si->pszModule, "TabPosition", (WORD)(i + 1)); + } + else db_unset(si->hContact, si->pszModule, "TabPosition"); + } + break; - case ID_CLOSEOTHER: - int tabCount = m_tab.GetCount() - 1; - if (tabCount > 0) { - for (tabCount; tabCount >= 0; tabCount--) { - if (tabCount == i) - continue; + case ID_CLOSEOTHER: + int tabCount = m_tab.GetCount() - 1; + if (tabCount > 0) { + for (tabCount; tabCount >= 0; tabCount--) { + if (tabCount == i) + continue; - m_tab.RemovePage(tabCount); + m_tab.RemovePage(tabCount); + } + m_tab.ActivatePage(0); } - m_tab.ActivatePage(0); + break; } - break; } } break; @@ -537,7 +544,4 @@ void ShowRoom(SESSION_INFO *si) ShowWindow(si->pDlg->GetHwnd(), SW_NORMAL); ShowWindow(si->pDlg->GetHwnd(), SW_SHOW); SetForegroundWindow(si->pDlg->GetHwnd()); - - SendMessage(si->pDlg->GetHwnd(), WM_MOUSEACTIVATE, 0, 0); - SetFocus(GetDlgItem(si->pDlg->GetHwnd(), IDC_MESSAGE)); } |