From d1a660dcebdaeca43201d695a7d22454b620521e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 4 Nov 2019 14:36:44 +0300 Subject: tabSRMM: - massive code cleaning; - fixes #2099 (TabSRMM: add tab scrolling by mouse wheel); - version bump --- plugins/TabSRMM/src/chat_main.cpp | 18 +- plugins/TabSRMM/src/chat_tools.cpp | 7 +- plugins/TabSRMM/src/container.cpp | 839 ++++++++++++++-------------- plugins/TabSRMM/src/containeroptions.cpp | 6 +- plugins/TabSRMM/src/controls.cpp | 8 +- plugins/TabSRMM/src/controls.h | 2 +- plugins/TabSRMM/src/functions.h | 5 - plugins/TabSRMM/src/generic_msghandlers.cpp | 25 +- plugins/TabSRMM/src/hotkeyhandler.cpp | 8 +- plugins/TabSRMM/src/infopanel.cpp | 10 +- plugins/TabSRMM/src/msgdialog.cpp | 2 +- plugins/TabSRMM/src/msgdlgother.cpp | 2 +- plugins/TabSRMM/src/msgdlgutils.cpp | 2 +- plugins/TabSRMM/src/msgoptions.cpp | 5 +- plugins/TabSRMM/src/msgs.cpp | 27 +- plugins/TabSRMM/src/msgs.h | 22 +- plugins/TabSRMM/src/sendqueue.cpp | 2 +- plugins/TabSRMM/src/sidebar.cpp | 63 +-- plugins/TabSRMM/src/themes.cpp | 2 +- plugins/TabSRMM/src/version.h | 2 +- 20 files changed, 521 insertions(+), 536 deletions(-) (limited to 'plugins/TabSRMM/src') diff --git a/plugins/TabSRMM/src/chat_main.cpp b/plugins/TabSRMM/src/chat_main.cpp index 883ae67149..2a9de1c2d8 100644 --- a/plugins/TabSRMM/src/chat_main.cpp +++ b/plugins/TabSRMM/src/chat_main.cpp @@ -255,19 +255,17 @@ void ShowRoom(TContainerData *pContainer, SESSION_INFO *si) } else wcsncpy_s(newcontactname, L"_U_", _TRUNCATE); - HWND hwndTab = GetDlgItem(pContainer->m_hwnd, IDC_MSGTABS); - // hide the active tab if (pContainer->m_hwndActive) ShowWindow(pContainer->m_hwndActive, SW_HIDE); int iTabIndex_wanted = M.GetDword(hContact, "tabindex", pContainer->m_iChilds * 100); - int iCount = TabCtrl_GetItemCount(hwndTab); + int iCount = TabCtrl_GetItemCount(pContainer->m_hwndTabs); pContainer->m_iTabIndex = iCount; if (iCount > 0) { for (int i = iCount - 1; i >= 0; i--) { - HWND hwnd = GetTabWindow(hwndTab, i); + HWND hwnd = GetTabWindow(pContainer->m_hwndTabs, i); CMsgDialog *dat = (CMsgDialog *)GetWindowLongPtr(hwnd, GWLP_USERDATA); if (dat) { int relPos = M.GetDword(dat->m_hContact, "tabindex", i * 100); @@ -280,21 +278,21 @@ void ShowRoom(TContainerData *pContainer, SESSION_INFO *si) TCITEM item = {}; item.pszText = newcontactname; item.mask = TCIF_TEXT | TCIF_IMAGE; - int iTabId = TabCtrl_InsertItem(hwndTab, pContainer->m_iTabIndex, &item); + int iTabId = TabCtrl_InsertItem(pContainer->m_hwndTabs, pContainer->m_iTabIndex, &item); - SendMessage(hwndTab, EM_REFRESHWITHOUTCLIP, 0, 0); - TabCtrl_SetCurSel(hwndTab, iTabId); + SendMessage(pContainer->m_hwndTabs, EM_REFRESHWITHOUTCLIP, 0, 0); + TabCtrl_SetCurSel(pContainer->m_hwndTabs, iTabId); pContainer->m_iChilds++; CMsgDialog *pDlg = new CMsgDialog(si); pDlg->m_iTabID = iTabId; pDlg->m_pContainer = pContainer; - pDlg->SetParent(hwndTab); + pDlg->SetParent(pContainer->m_hwndTabs); pDlg->Create(); HWND hwndNew = pDlg->GetHwnd(); item.lParam = (LPARAM)hwndNew; - TabCtrl_SetItem(hwndTab, iTabId, &item); + TabCtrl_SetItem(pContainer->m_hwndTabs, iTabId, &item); if (pContainer->m_flags.m_bSideBar) pContainer->m_pSideBar->addSession(pDlg, pContainer->m_iTabIndex); @@ -311,7 +309,7 @@ void ShowRoom(TContainerData *pContainer, SESSION_INFO *si) wp.length = sizeof(wp); GetWindowPlacement(pContainer->m_hwnd, &wp); - BroadCastContainer(pContainer, DM_CHECKSIZE, 0, 0); // make sure all tabs will re-check layout on activation + pContainer->BroadCastContainer(DM_CHECKSIZE, 0, 0); // make sure all tabs will re-check layout on activation if (wp.showCmd == SW_SHOWMAXIMIZED) ShowWindow(pContainer->m_hwnd, SW_SHOWMAXIMIZED); else { diff --git a/plugins/TabSRMM/src/chat_tools.cpp b/plugins/TabSRMM/src/chat_tools.cpp index 492a4a4cf1..2d195b75a2 100644 --- a/plugins/TabSRMM/src/chat_tools.cpp +++ b/plugins/TabSRMM/src/chat_tools.cpp @@ -222,7 +222,6 @@ void DoFlashAndSoundWorker(FLASH_PARAMS *p) Skin_PlaySound(p->sound); if (dat) { - HWND hwndTab = GetParent(si->pDlg->GetHwnd()); BOOL bForcedIcon = (p->hNotifyIcon == g_chatApi.hIcons[ICON_HIGHLIGHT] || p->hNotifyIcon == g_chatApi.hIcons[ICON_MESSAGE]); if ((p->iEvent & si->iLogTrayFlags) || bForcedIcon) { @@ -245,9 +244,9 @@ void DoFlashAndSoundWorker(FLASH_PARAMS *p) // autoswitch tab.. if (p->bMustAutoswitch) { if ((IsIconic(dat->m_pContainer->m_hwnd)) && !IsZoomed(dat->m_pContainer->m_hwnd) && PluginConfig.m_bAutoSwitchTabs && dat->m_pContainer->m_hwndActive != si->pDlg->GetHwnd()) { - int iItem = GetTabIndexFromHWND(hwndTab, si->pDlg->GetHwnd()); + int iItem = GetTabIndexFromHWND(dat->m_pContainer->m_hwndTabs, si->pDlg->GetHwnd()); if (iItem >= 0) { - TabCtrl_SetCurSel(hwndTab, iItem); + TabCtrl_SetCurSel(dat->m_pContainer->m_hwndTabs, iItem); ShowWindow(dat->m_pContainer->m_hwndActive, SW_HIDE); dat->m_pContainer->m_hwndActive = si->pDlg->GetHwnd(); dat->m_pContainer->UpdateTitle(dat->m_hContact); @@ -259,7 +258,7 @@ void DoFlashAndSoundWorker(FLASH_PARAMS *p) // flash window if it is not focused if (p->bMustFlash && p->bInactive) if (!dat->m_pContainer->m_flags.m_bNoFlash) - FlashContainer(dat->m_pContainer, 1, 0); + dat->m_pContainer->FlashContainer(1, 0); if (p->hNotifyIcon && p->bInactive && ((p->iEvent & si->iLogTrayFlags) || bForcedIcon)) { if (p->bMustFlash) diff --git a/plugins/TabSRMM/src/container.cpp b/plugins/TabSRMM/src/container.cpp index cf69ba81a8..bbe52c6647 100644 --- a/plugins/TabSRMM/src/container.cpp +++ b/plugins/TabSRMM/src/container.cpp @@ -59,10 +59,77 @@ TContainerData::~TContainerData() mir_free(m_pSettings); } +///////////////////////////////////////////////////////////////////////////////////////// +// calls the TabCtrl_AdjustRect to calculate the "real" client area of the tab. +// also checks for the option "hide tabs when only one tab open" and adjusts +// geometry if necessary +// rc is the RECT obtained by GetClientRect(hwndTab) + +void TContainerData::AdjustTabClientRect(RECT &rc) +{ + DWORD dwStyle = GetWindowLongPtr(m_hwndTabs, GWL_STYLE); + + RECT rcTab, rcTabOrig; + GetClientRect(m_hwndTabs, &rcTab); + if (!m_flags.m_bSideBar && (m_iChilds > 1 || !m_flags.m_bHideTabs)) { + rcTabOrig = rcTab; + TabCtrl_AdjustRect(m_hwndTabs, FALSE, &rcTab); + DWORD dwTopPad = rcTab.top - rcTabOrig.top; + + rc.left += m_tBorder; + rc.right -= m_tBorder; + + if (dwStyle & TCS_BUTTONS) { + if (m_flags.m_bTabsBottom) { + int nCount = TabCtrl_GetItemCount(m_hwndTabs); + if (nCount > 0) { + RECT rcItem; + TabCtrl_GetItemRect(m_hwndTabs, nCount - 1, &rcItem); + rc.bottom = rcItem.top; + } + } + else { + rc.top += (dwTopPad - 2); + rc.bottom = rcTabOrig.bottom; + } + } + else { + if (m_flags.m_bTabsBottom) + rc.bottom = rcTab.bottom + 2; + else { + rc.top += (dwTopPad - 2); + rc.bottom = rcTabOrig.bottom; + } + } + + rc.top += m_tBorder; + rc.bottom -= m_tBorder; + } + else { + rc.bottom = rcTab.bottom; + rc.top = rcTab.top; + } + rc.right -= (m_tBorder_outer_left + m_tBorder_outer_right); + if (m_pSideBar->isVisible()) + rc.right -= m_pSideBar->getWidth(); +} + +///////////////////////////////////////////////////////////////////////////////////////// +// broadcasts a message to all child windows (tabs/sessions) + +void TContainerData::BroadCastContainer(UINT message, WPARAM wParam, LPARAM lParam) const +{ + int nCount = TabCtrl_GetItemCount(m_hwndTabs); + for (int i = 0; i < nCount; i++) { + HWND hDlg = GetTabWindow(m_hwndTabs, i); + if (IsWindow(hDlg)) + SendMessage(hDlg, message, wParam, lParam); + } +} + void TContainerData::CloseTabByMouse(POINT *pt) { - HWND hwndTab = GetDlgItem(m_hwnd, IDC_MSGTABS); - if (HWND hDlg = GetTabWindow(hwndTab, GetTabItemFromMouse(hwndTab, pt))) { + if (HWND hDlg = GetTabWindow(m_hwndTabs, GetTabItemFromMouse(m_hwndTabs, pt))) { if (hDlg != m_hwndActive) { m_bDontSmartClose = true; SendMessage(hDlg, WM_CLOSE, 0, 1); @@ -123,15 +190,14 @@ void TContainerData::Configure() m_flags.m_bSideBar = m_flagsEx.m_bTabSBarLeft || m_flagsEx.m_bTabSBarRight; m_pSideBar->Init(); - HWND hwndTab = GetDlgItem(m_hwnd, IDC_MSGTABS); - ws = wsold = GetWindowLong(hwndTab, GWL_STYLE); + ws = wsold = GetWindowLong(m_hwndTabs, GWL_STYLE); if (m_flags.m_bTabsBottom) ws |= TCS_BOTTOM; else ws &= ~TCS_BOTTOM; if ((ws & (TCS_BOTTOM | TCS_MULTILINE)) != (wsold & (TCS_BOTTOM | TCS_MULTILINE))) { - SetWindowLong(hwndTab, GWL_STYLE, ws); - RedrawWindow(hwndTab, nullptr, nullptr, RDW_INVALIDATE); + SetWindowLong(m_hwndTabs, GWL_STYLE, ws); + RedrawWindow(m_hwndTabs, nullptr, nullptr, RDW_INVALIDATE); } if (m_flags.m_bNoStatusBar) { @@ -155,7 +221,110 @@ void TContainerData::Configure() UpdateTitle(hContact); } SendMessage(m_hwnd, WM_SIZE, 0, 1); - BroadCastContainer(this, DM_CONFIGURETOOLBAR, 0, 1); + BroadCastContainer(DM_CONFIGURETOOLBAR, 0, 1); +} + +void TContainerData::InitDialog(HWND hwndDlg) +{ + m_hwnd = hwndDlg; + m_hwndTabs = ::GetDlgItem(hwndDlg, IDC_MSGTABS); + { + DWORD dwCreateFlags = m_flags.dw; + m_isCloned = m_flags.m_bCreateCloned; + m_fPrivateThemeChanged = FALSE; + + ::SendMessage(hwndDlg, DM_OPTIONSAPPLIED, 0, 0); // set options... + m_flags.dw |= dwCreateFlags; + + LoadOverrideTheme(); + DWORD ws = ::GetWindowLong(m_hwndTabs, GWL_STYLE); + if (m_flagsEx.m_bTabFlat) + ws |= TCS_BUTTONS; + + ClearMargins(); + + if (m_flagsEx.m_bTabSingleRow) { + ws &= ~TCS_MULTILINE; + ws |= TCS_SINGLELINE; + ws |= TCS_FIXEDWIDTH; + } + else { + ws &= ~TCS_SINGLELINE; + ws |= TCS_MULTILINE; + if (ws & TCS_BUTTONS) + ws |= TCS_FIXEDWIDTH; + } + ::SetWindowLong(m_hwndTabs, GWL_STYLE, ws); + + m_buttonItems = g_ButtonSet.items; + + m_flags.m_bSideBar = m_flagsEx.m_bTabSBarLeft || m_flagsEx.m_bTabSBarRight; + m_pSideBar = new CSideBar(this); + m_pMenuBar = new CMenuBar(this); + + ::SetClassLong(hwndDlg, GCL_STYLE, ::GetClassLong(hwndDlg, GCL_STYLE) & ~(CS_VREDRAW | CS_HREDRAW | CS_DROPSHADOW)); + ::SetClassLong(m_hwndTabs, GCL_STYLE, ::GetClassLong(m_hwndTabs, GCL_STYLE) & ~(CS_VREDRAW | CS_HREDRAW)); + + // additional system menu items... + HMENU hSysmenu = GetSystemMenu(hwndDlg, FALSE); + int iMenuItems = GetMenuItemCount(hSysmenu); + + ::InsertMenu(hSysmenu, iMenuItems++ - 2, MF_BYPOSITION | MF_SEPARATOR, 0, L""); + ::InsertMenu(hSysmenu, iMenuItems++ - 2, MF_BYPOSITION | MF_STRING, IDM_STAYONTOP, TranslateT("Stay on top")); + if (!CSkin::m_frameSkins) + ::InsertMenu(hSysmenu, iMenuItems++ - 2, MF_BYPOSITION | MF_STRING, IDM_NOTITLE, TranslateT("Hide title bar")); + ::InsertMenu(hSysmenu, iMenuItems++ - 2, MF_BYPOSITION | MF_SEPARATOR, 0, L""); + ::InsertMenu(hSysmenu, iMenuItems++ - 2, MF_BYPOSITION | MF_STRING, IDM_MOREOPTIONS, TranslateT("Container options...")); + ::SetWindowText(hwndDlg, TranslateT("Message session...")); + ::SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)PluginConfig.g_iconContainer); + + // make the tab control the controlling parent window for all message dialogs + + ws = ::GetWindowLong(m_hwndTabs, GWL_EXSTYLE); + ::SetWindowLong(m_hwndTabs, GWL_EXSTYLE, ws | WS_EX_CONTROLPARENT); + + LONG x_pad = M.GetByte("x-pad", 3) + (m_flagsEx.m_bTabCloseButton ? 7 : 0); + LONG y_pad = M.GetByte("y-pad", 3) + ((m_flags.m_bTabsBottom) ? 1 : 0); + + if (m_flagsEx.m_bTabFlat) + y_pad++; //(m_flags.m_bTabsBottom ? 1 : 2); + + TabCtrl_SetPadding(m_hwndTabs, x_pad, y_pad); + + TabCtrl_SetImageList(m_hwndTabs, PluginConfig.g_hImageList); + + Configure(); + + // tab tooltips... + if (!::ServiceExists("mToolTip/ShowTip") || M.GetByte("d_tooltips", 0) == 0) { + m_hwndTip = ::CreateWindowEx(0, TOOLTIPS_CLASS, nullptr, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, + CW_USEDEFAULT, CW_USEDEFAULT, hwndDlg, nullptr, g_plugin.getInst(), (LPVOID)nullptr); + + if (m_hwndTip) { + ::SetWindowPos(m_hwndTip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); + TabCtrl_SetToolTips(m_hwndTabs, m_hwndTip); + } + } + else m_hwndTip = nullptr; + + if (m_flags.m_bCreateMinimized) { + SetWindowLongPtr(hwndDlg, GWL_STYLE, GetWindowLongPtr(hwndDlg, GWL_STYLE) & ~WS_VISIBLE); + ::ShowWindow(hwndDlg, SW_SHOWMINNOACTIVE); + RestoreWindowPos(); + ::ShowWindow(hwndDlg, SW_SHOWMINNOACTIVE); + + WINDOWPLACEMENT wp = {}; + wp.length = sizeof(wp); + ::GetWindowPlacement(hwndDlg, &wp); + m_rcSaved.left = m_rcSaved.top = 0; + m_rcSaved.right = wp.rcNormalPosition.right - wp.rcNormalPosition.left; + m_rcSaved.bottom = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top; + } + else { + RestoreWindowPos(); + ::ShowWindow(hwndDlg, SW_SHOWNORMAL); + } + } } void TContainerData::InitRedraw() @@ -238,10 +407,9 @@ void TContainerData::QueryPending() DWORD dwMostRecent = 0; HWND hwndMostRecent = nullptr; - HWND hwndTab = GetDlgItem(m_hwnd, IDC_MSGTABS); - int iItems = TabCtrl_GetItemCount(hwndTab); + int iItems = TabCtrl_GetItemCount(m_hwndTabs); for (int i = 0; i < iItems; i++) { - HWND hDlg = GetTabWindow(hwndTab, i); + HWND hDlg = GetTabWindow(m_hwndTabs, i); DWORD dwTimestamp; SendMessage(hDlg, DM_QUERYLASTUNREAD, 0, (LPARAM)&dwTimestamp); if (dwTimestamp > dwMostRecent) { @@ -252,7 +420,7 @@ void TContainerData::QueryPending() } if (iMostRecent != -1) { - TabCtrl_SetCurSel(hwndTab, iMostRecent); + TabCtrl_SetCurSel(m_hwndTabs, iMostRecent); NMHDR nmhdr; nmhdr.code = TCN_SELCHANGE; @@ -260,6 +428,34 @@ void TContainerData::QueryPending() } } +void TContainerData::ReflashContainer() +{ + if (IsActive()) // dont care about active windows + return; + + if (m_flags.m_bNoFlash || m_dwFlashingStarted == 0) + return; // dont care about containers which should never flash + + DWORD dwStartTime = m_dwFlashingStarted; + + if (m_flags.m_bFlashAlways) + FlashContainer(1, 0); + else { + // recalc the remaining flashes + DWORD dwInterval = M.GetDword("flashinterval", 1000); + int iFlashesElapsed = (GetTickCount() - dwStartTime) / dwInterval; + DWORD dwFlashesDesired = M.GetByte("nrflash", 4); + if (iFlashesElapsed < (int)dwFlashesDesired) + FlashContainer(1, dwFlashesDesired - iFlashesElapsed); + else { + BOOL isFlashed = FlashWindow(m_hwnd, TRUE); + if (!isFlashed) + FlashWindow(m_hwnd, TRUE); + } + } + m_dwFlashingStarted = dwStartTime; +} + // retrieve the container window geometry information from the database. void TContainerData::RestoreWindowPos() { @@ -290,23 +486,115 @@ void TContainerData::RestoreWindowPos() } } -void TContainerData::SelectTab(int iCommand, int idx) +void TContainerData::Resize(bool bRestored, int newWidth) { - HWND hwndTab = GetDlgItem(m_hwnd, IDC_MSGTABS); + RECT rcClient, rcUnadjusted; + + GetClientRect(m_hwnd, &rcClient); + m_pMenuBar->getClientRect(); + + if (m_hwndStatus) { + auto *dat = (CMsgDialog *)GetWindowLongPtr(m_hwndActive, GWLP_USERDATA); + SendMessage(m_hwndStatus, WM_USER + 101, 0, (LPARAM)dat); + + RECT rcs; + GetWindowRect(m_hwndStatus, &rcs); + m_statusBarHeight = (rcs.bottom - rcs.top) + 1; + SendMessage(m_hwndStatus, SB_SETTEXT, (WPARAM)(SBT_OWNERDRAW) | 2, 0); + } + else m_statusBarHeight = 0; + + CopyRect(&m_rcSaved, &rcClient); + rcUnadjusted = rcClient; + + m_pMenuBar->Resize(newWidth); + LONG rebarHeight = m_pMenuBar->getHeight(); + m_pMenuBar->Show((m_flags.m_bNoMenuBar) ? SW_HIDE : SW_SHOW); + + LONG sbarWidth = m_pSideBar->getWidth(); + LONG sbarWidth_left = m_pSideBar->getFlags() & CSideBar::SIDEBARORIENTATION_LEFT ? sbarWidth : 0; + + if (newWidth) { + SetWindowPos(m_hwndTabs, nullptr, m_tBorder_outer_left + sbarWidth_left, m_tBorder_outer_top + rebarHeight, + (rcClient.right - rcClient.left) - (m_tBorder_outer_left + m_tBorder_outer_right + sbarWidth), + (rcClient.bottom - rcClient.top) - m_statusBarHeight - (m_tBorder_outer_top + m_tBorder_outer_bottom) - rebarHeight, + SWP_NOACTIVATE | SWP_NOZORDER | SWP_DEFERERASE | SWP_NOCOPYBITS); + } + + m_pSideBar->resizeScrollWnd(sbarWidth_left ? m_tBorder_outer_left : rcClient.right - m_tBorder_outer_right - (sbarWidth - 2), + m_tBorder_outer_top + rebarHeight, 0, + (rcClient.bottom - rcClient.top) - m_statusBarHeight - (m_tBorder_outer_top + m_tBorder_outer_bottom) - rebarHeight); + + AdjustTabClientRect(rcClient); + + BOOL sizeChanged = (((rcClient.right - rcClient.left) != m_preSIZE.cx) || ((rcClient.bottom - rcClient.top) != m_preSIZE.cy)); + if (sizeChanged) { + m_preSIZE.cx = rcClient.right - rcClient.left; + m_preSIZE.cy = rcClient.bottom - rcClient.top; + } + + // we care about all client sessions, but we really resize only the active tab (hwndActive) + // we tell inactive tabs to resize theirselves later when they get activated (DM_CHECKSIZE + // just queues a resize request) + int nCount = TabCtrl_GetItemCount(m_hwndTabs); + for (int i = 0; i < nCount; i++) { + HWND hDlg = GetTabWindow(m_hwndTabs, i); + if (hDlg == m_hwndActive) { + SetWindowPos(hDlg, nullptr, rcClient.left, rcClient.top, (rcClient.right - rcClient.left), (rcClient.bottom - rcClient.top), + SWP_NOSENDCHANGING | SWP_NOACTIVATE/*|SWP_NOCOPYBITS*/); + if (!m_bSizingLoop && sizeChanged) { + auto *dat = (CMsgDialog *)GetWindowLongPtr(m_hwndActive, GWLP_USERDATA); + if (dat) + dat->DM_ScrollToBottom(0, 1); + } + } + else if (sizeChanged) + SendMessage(hDlg, DM_CHECKSIZE, 0, 0); + } + m_pSideBar->scrollIntoView(); + + if (!M.isAero()) { // aero mode uses buffered paint, no forced redraw needed + RedrawWindow(m_hwndTabs, nullptr, nullptr, RDW_INVALIDATE | (m_bSizingLoop ? RDW_ERASE : 0)); + RedrawWindow(m_hwnd, nullptr, nullptr, (CSkin::m_skinEnabled ? RDW_FRAME : 0) | RDW_INVALIDATE | ((m_bSizingLoop || bRestored) ? RDW_ERASE : 0)); + } + + if (m_hwndStatus) + InvalidateRect(m_hwndStatus, nullptr, FALSE); + + if ((CSkin::m_bClipBorder != 0 || CSkin::m_bRoundedCorner) && CSkin::m_frameSkins) { + HRGN rgn; + int clip = CSkin::m_bClipBorder; + + RECT rcWindow; + GetWindowRect(m_hwnd, &rcWindow); + + if (CSkin::m_bRoundedCorner) + rgn = CreateRoundRectRgn(clip, clip, (rcWindow.right - rcWindow.left) - clip + 1, + (rcWindow.bottom - rcWindow.top) - clip + 1, CSkin::m_bRoundedCorner + clip, CSkin::m_bRoundedCorner + clip); + else + rgn = CreateRectRgn(clip, clip, (rcWindow.right - rcWindow.left) - clip, (rcWindow.bottom - rcWindow.top) - clip); + SetWindowRgn(m_hwnd, rgn, TRUE); + } + else if (CSkin::m_frameSkins) + SetWindowRgn(m_hwnd, nullptr, TRUE); +} + +void TContainerData::SelectTab(int iCommand, int idx) +{ switch (iCommand) { case DM_SELECT_BY_HWND: - ActivateTabFromHWND(hwndTab, (HWND)idx); + ActivateTabFromHWND(m_hwndTabs, (HWND)idx); break; case DM_SELECT_NEXT: case DM_SELECT_PREV: case DM_SELECT_BY_INDEX: - int iItems = TabCtrl_GetItemCount(hwndTab); + int iItems = TabCtrl_GetItemCount(m_hwndTabs); if (iItems == 1) break; - int iCurrent = TabCtrl_GetCurSel(hwndTab), iNewTab; + int iCurrent = TabCtrl_GetCurSel(m_hwndTabs), iNewTab; if (iCommand == DM_SELECT_PREV) iNewTab = iCurrent ? iCurrent - 1 : iItems - 1; // cycle if current is already the leftmost tab.. @@ -319,8 +607,8 @@ void TContainerData::SelectTab(int iCommand, int idx) } if (iNewTab != iCurrent) { - if (HWND hDlg = GetTabWindow(hwndTab, iNewTab)) { - TabCtrl_SetCurSel(hwndTab, iNewTab); + if (HWND hDlg = GetTabWindow(m_hwndTabs, iNewTab)) { + TabCtrl_SetCurSel(m_hwndTabs, iNewTab); ShowWindow(m_hwndActive, SW_HIDE); m_hwndActive = hDlg; ShowWindow(hDlg, SW_SHOW); @@ -331,6 +619,67 @@ void TContainerData::SelectTab(int iCommand, int idx) } } +///////////////////////////////////////////////////////////////////////////////////////// +// Windows Vista+ +// extend the glassy area to get aero look for the status bar, tab bar, info panel +// and outer margins. + +void TContainerData::SetAeroMargins() +{ + if (!M.isAero() || CSkin::m_skinEnabled) { + m_pMenuBar->setAero(false); + return; + } + + CMsgDialog *dat = (CMsgDialog *)::GetWindowLongPtr(m_hwndActive, GWLP_USERDATA); + if (!dat) + return; + + RECT rcWnd; + if (dat->m_pPanel.isActive()) + ::GetWindowRect(::GetDlgItem(dat->GetHwnd(), IDC_SRMM_LOG), &rcWnd); + else + ::GetWindowRect(dat->GetHwnd(), &rcWnd); + + POINT pt = { rcWnd.left, rcWnd.top }; + ::ScreenToClient(m_hwnd, &pt); + + MARGINS m; + m.cyTopHeight = pt.y; + m_pMenuBar->setAero(true); + + // bottom part + ::GetWindowRect(dat->GetHwnd(), &rcWnd); + pt.x = rcWnd.left; + + LONG sbar_left, sbar_right; + if (!m_pSideBar->isActive()) { + pt.y = rcWnd.bottom + ((m_iChilds > 1 || !m_flags.m_bHideTabs) ? m_tBorder : 0); + sbar_left = 0, sbar_right = 0; + } + else { + pt.y = rcWnd.bottom; + sbar_left = (m_pSideBar->getFlags() & CSideBar::SIDEBARORIENTATION_LEFT ? m_pSideBar->getWidth() : 0); + sbar_right = (m_pSideBar->getFlags() & CSideBar::SIDEBARORIENTATION_RIGHT ? m_pSideBar->getWidth() : 0); + } + ::ScreenToClient(m_hwnd, &pt); + ::GetClientRect(m_hwnd, &rcWnd); + m.cyBottomHeight = (rcWnd.bottom - pt.y); + + if (m.cyBottomHeight < 0 || m.cyBottomHeight >= rcWnd.bottom) + m.cyBottomHeight = 0; + + m.cxLeftWidth = m_tBorder_outer_left; + m.cxRightWidth = m_tBorder_outer_right; + m.cxLeftWidth += sbar_left; + m.cxRightWidth += sbar_right; + + if (memcmp(&m, &m_mOld, sizeof(MARGINS)) != 0) { + m_mOld = m; + CMimAPI::m_pfnDwmExtendFrameIntoClientArea(m_hwnd, &m); + } +} + void TContainerData::SetIcon(CMsgDialog *pDlg, HICON hIcon) { HICON hIconMsg = PluginConfig.g_IconMsgEvent; @@ -397,10 +746,9 @@ void TContainerData::SetIcon(CMsgDialog *pDlg, HICON hIcon) void TContainerData::UpdateTabs() { - HWND hwndTab = GetDlgItem(m_hwnd, IDC_MSGTABS); - int nTabs = TabCtrl_GetItemCount(hwndTab); + int nTabs = TabCtrl_GetItemCount(m_hwndTabs); for (int i = 0; i < nTabs; i++) { - HWND hDlg = GetTabWindow(hwndTab, i); + HWND hDlg = GetTabWindow(m_hwndTabs, i); if (!hDlg) continue; @@ -441,68 +789,8 @@ void TContainerData::UpdateTitle(MCONTACT hContact, CMsgDialog *pDlg) } } -// Windows Vista+ -// extend the glassy area to get aero look for the status bar, tab bar, info panel -// and outer margins. - -void TSAPI SetAeroMargins(TContainerData *pContainer) -{ - if (!pContainer) - return; - - if (!M.isAero() || CSkin::m_skinEnabled) { - pContainer->m_pMenuBar->setAero(false); - return; - } - - CMsgDialog *dat = (CMsgDialog*)GetWindowLongPtr(pContainer->m_hwndActive, GWLP_USERDATA); - if (!dat) - return; - - RECT rcWnd; - if (dat->m_pPanel.isActive()) - GetWindowRect(GetDlgItem(dat->GetHwnd(), IDC_SRMM_LOG), &rcWnd); - else - GetWindowRect(dat->GetHwnd(), &rcWnd); - - POINT pt = { rcWnd.left, rcWnd.top }; - ScreenToClient(pContainer->m_hwnd, &pt); - - MARGINS m; - m.cyTopHeight = pt.y; - pContainer->m_pMenuBar->setAero(true); - - // bottom part - GetWindowRect(dat->GetHwnd(), &rcWnd); - pt.x = rcWnd.left; - - LONG sbar_left, sbar_right; - if (!pContainer->m_pSideBar->isActive()) { - pt.y = rcWnd.bottom + ((pContainer->m_iChilds > 1 || !pContainer->m_flags.m_bHideTabs) ? pContainer->m_tBorder : 0); - sbar_left = 0, sbar_right = 0; - } - else { - pt.y = rcWnd.bottom; - sbar_left = (pContainer->m_pSideBar->getFlags() & CSideBar::SIDEBARORIENTATION_LEFT ? pContainer->m_pSideBar->getWidth() : 0); - sbar_right = (pContainer->m_pSideBar->getFlags() & CSideBar::SIDEBARORIENTATION_RIGHT ? pContainer->m_pSideBar->getWidth() : 0); - } - ScreenToClient(pContainer->m_hwnd, &pt); - GetClientRect(pContainer->m_hwnd, &rcWnd); - m.cyBottomHeight = (rcWnd.bottom - pt.y); - - if (m.cyBottomHeight < 0 || m.cyBottomHeight >= rcWnd.bottom) - m.cyBottomHeight = 0; - - m.cxLeftWidth = pContainer->m_tBorder_outer_left; - m.cxRightWidth = pContainer->m_tBorder_outer_right; - m.cxLeftWidth += sbar_left; - m.cxRightWidth += sbar_right; - - if (memcmp(&m, &pContainer->m_mOld, sizeof(MARGINS)) != 0) { - pContainer->m_mOld = m; - CMimAPI::m_pfnDwmExtendFrameIntoClientArea(pContainer->m_hwnd, &m); - } -} +///////////////////////////////////////////////////////////////////////////////////////// +// Window procedure (subclassed) static LRESULT CALLBACK ContainerWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -839,8 +1127,6 @@ static LRESULT CALLBACK ContainerWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, ///////////////////////////////////////////////////////////////////////////////////////// // container window procedure... -static BOOL fHaveTipper = FALSE; - static INT_PTR CALLBACK DlgProcContainer(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { RECT rc; @@ -849,119 +1135,15 @@ static INT_PTR CALLBACK DlgProcContainer(HWND hwndDlg, UINT msg, WPARAM wParam, CMsgDialog *dat; TContainerData *pContainer = (TContainerData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - HWND hwndTab = GetDlgItem(hwndDlg, IDC_MSGTABS); switch (msg) { case WM_INITDIALOG: - fHaveTipper = ServiceExists("mToolTip/ShowTip"); fForceOverlayIcons = M.GetByte("forceTaskBarStatusOverlays", 0) ? true : false; pContainer = (TContainerData*)lParam; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)pContainer); mir_subclassWindow(hwndDlg, ContainerWndProc); - - pContainer->m_hwnd = hwndDlg; - { - DWORD dwCreateFlags = pContainer->m_flags.dw; - pContainer->m_isCloned = pContainer->m_flags.m_bCreateCloned; - pContainer->m_fPrivateThemeChanged = FALSE; - - SendMessage(hwndDlg, DM_OPTIONSAPPLIED, 0, 0); // set options... - pContainer->m_flags.dw |= dwCreateFlags; - - pContainer->LoadOverrideTheme(); - DWORD ws = GetWindowLongPtr(hwndTab, GWL_STYLE); - if (pContainer->m_flagsEx.m_bTabFlat) - ws |= TCS_BUTTONS; - - pContainer->ClearMargins(); - - if (pContainer->m_flagsEx.m_bTabSingleRow) { - ws &= ~TCS_MULTILINE; - ws |= TCS_SINGLELINE; - ws |= TCS_FIXEDWIDTH; - } - else { - ws &= ~TCS_SINGLELINE; - ws |= TCS_MULTILINE; - if (ws & TCS_BUTTONS) - ws |= TCS_FIXEDWIDTH; - } - SetWindowLongPtr(hwndTab, GWL_STYLE, ws); - - pContainer->m_buttonItems = g_ButtonSet.items; - - pContainer->m_flags.m_bSideBar = pContainer->m_flagsEx.m_bTabSBarLeft || pContainer->m_flagsEx.m_bTabSBarRight; - pContainer->m_pSideBar = new CSideBar(pContainer); - - pContainer->m_pMenuBar = new CMenuBar(hwndDlg, pContainer); - - SetClassLongPtr(hwndDlg, GCL_STYLE, GetClassLongPtr(hwndDlg, GCL_STYLE) & ~(CS_VREDRAW | CS_HREDRAW)); - SetClassLongPtr(hwndTab, GCL_STYLE, GetClassLongPtr(hwndTab, GCL_STYLE) & ~(CS_VREDRAW | CS_HREDRAW)); - - SetClassLongPtr(hwndDlg, GCL_STYLE, GetClassLongPtr(hwndDlg, GCL_STYLE) & ~CS_DROPSHADOW); - - // additional system menu items... - HMENU hSysmenu = GetSystemMenu(hwndDlg, FALSE); - int iMenuItems = GetMenuItemCount(hSysmenu); - - InsertMenu(hSysmenu, iMenuItems++ - 2, MF_BYPOSITION | MF_SEPARATOR, 0, L""); - InsertMenu(hSysmenu, iMenuItems++ - 2, MF_BYPOSITION | MF_STRING, IDM_STAYONTOP, TranslateT("Stay on top")); - if (!CSkin::m_frameSkins) - InsertMenu(hSysmenu, iMenuItems++ - 2, MF_BYPOSITION | MF_STRING, IDM_NOTITLE, TranslateT("Hide title bar")); - InsertMenu(hSysmenu, iMenuItems++ - 2, MF_BYPOSITION | MF_SEPARATOR, 0, L""); - InsertMenu(hSysmenu, iMenuItems++ - 2, MF_BYPOSITION | MF_STRING, IDM_MOREOPTIONS, TranslateT("Container options...")); - SetWindowText(hwndDlg, TranslateT("Message session...")); - SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)PluginConfig.g_iconContainer); - - // make the tab control the controlling parent window for all message dialogs - - ws = GetWindowLongPtr(hwndTab, GWL_EXSTYLE); - SetWindowLongPtr(hwndTab, GWL_EXSTYLE, ws | WS_EX_CONTROLPARENT); - - LONG x_pad = M.GetByte("x-pad", 3) + (pContainer->m_flagsEx.m_bTabCloseButton ? 7 : 0); - LONG y_pad = M.GetByte("y-pad", 3) + ((pContainer->m_flags.m_bTabsBottom) ? 1 : 0); - - if (pContainer->m_flagsEx.m_bTabFlat) - y_pad++; //(pContainer->m_flags.m_bTabsBottom ? 1 : 2); - - TabCtrl_SetPadding(hwndTab, x_pad, y_pad); - - TabCtrl_SetImageList(hwndTab, PluginConfig.g_hImageList); - - pContainer->Configure(); - - // tab tooltips... - if (!fHaveTipper || M.GetByte("d_tooltips", 0) == 0) { - pContainer->m_hwndTip = CreateWindowEx(0, TOOLTIPS_CLASS, nullptr, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, - CW_USEDEFAULT, CW_USEDEFAULT, hwndDlg, nullptr, g_plugin.getInst(), (LPVOID)nullptr); - - if (pContainer->m_hwndTip) { - SetWindowPos(pContainer->m_hwndTip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); - TabCtrl_SetToolTips(hwndTab, pContainer->m_hwndTip); - } - } - else pContainer->m_hwndTip = nullptr; - - if (pContainer->m_flags.m_bCreateMinimized) { - SetWindowLongPtr(hwndDlg, GWL_STYLE, GetWindowLongPtr(hwndDlg, GWL_STYLE) & ~WS_VISIBLE); - ShowWindow(hwndDlg, SW_SHOWMINNOACTIVE); - pContainer->RestoreWindowPos(); - //GetClientRect(hwndDlg, &pContainer->m_rcSaved); - ShowWindow(hwndDlg, SW_SHOWMINNOACTIVE); - - WINDOWPLACEMENT wp = {}; - wp.length = sizeof(wp); - GetWindowPlacement(hwndDlg, &wp); - pContainer->m_rcSaved.left = pContainer->m_rcSaved.top = 0; - pContainer->m_rcSaved.right = wp.rcNormalPosition.right - wp.rcNormalPosition.left; - pContainer->m_rcSaved.bottom = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top; - } - else { - pContainer->RestoreWindowPos(); - ShowWindow(hwndDlg, SW_SHOWNORMAL); - } - } + pContainer->InitDialog(hwndDlg); // prevent ugly back background being visible while tabbed clients are created if (M.isAero()) { @@ -973,98 +1155,8 @@ static INT_PTR CALLBACK DlgProcContainer(HWND hwndDlg, UINT msg, WPARAM wParam, case WM_SIZE: if (IsIconic(hwndDlg)) pContainer->m_flags.m_bDeferredResize = true; - else { - RECT rcClient, rcUnadjusted; - - GetClientRect(hwndDlg, &rcClient); - pContainer->m_pMenuBar->getClientRect(); - - if (pContainer->m_hwndStatus) { - dat = (CMsgDialog*)GetWindowLongPtr(pContainer->m_hwndActive, GWLP_USERDATA); - SendMessage(pContainer->m_hwndStatus, WM_USER + 101, 0, (LPARAM)dat); - - RECT rcs; - GetWindowRect(pContainer->m_hwndStatus, &rcs); - pContainer->m_statusBarHeight = (rcs.bottom - rcs.top) + 1; - SendMessage(pContainer->m_hwndStatus, SB_SETTEXT, (WPARAM)(SBT_OWNERDRAW) | 2, 0); - } - else pContainer->m_statusBarHeight = 0; - - CopyRect(&pContainer->m_rcSaved, &rcClient); - rcUnadjusted = rcClient; - - pContainer->m_pMenuBar->Resize(LOWORD(lParam)); - LONG rebarHeight = pContainer->m_pMenuBar->getHeight(); - pContainer->m_pMenuBar->Show((pContainer->m_flags.m_bNoMenuBar) ? SW_HIDE : SW_SHOW); - - LONG sbarWidth = pContainer->m_pSideBar->getWidth(); - LONG sbarWidth_left = pContainer->m_pSideBar->getFlags() & CSideBar::SIDEBARORIENTATION_LEFT ? sbarWidth : 0; - - if (lParam) { - DWORD dwSWPFlags = SWP_NOACTIVATE | SWP_NOZORDER | SWP_DEFERERASE | SWP_NOCOPYBITS; // | SWP_NOSENDCHANGING | SWP_ASYNCWINDOWPOS; - SetWindowPos(hwndTab, nullptr, pContainer->m_tBorder_outer_left + sbarWidth_left, pContainer->m_tBorder_outer_top + rebarHeight, - (rcClient.right - rcClient.left) - (pContainer->m_tBorder_outer_left + pContainer->m_tBorder_outer_right + sbarWidth), - (rcClient.bottom - rcClient.top) - pContainer->m_statusBarHeight - (pContainer->m_tBorder_outer_top + pContainer->m_tBorder_outer_bottom) - rebarHeight, dwSWPFlags); - } - - pContainer->m_pSideBar->resizeScrollWnd(sbarWidth_left ? pContainer->m_tBorder_outer_left : rcClient.right - pContainer->m_tBorder_outer_right - (sbarWidth - 2), - pContainer->m_tBorder_outer_top + rebarHeight, 0, - (rcClient.bottom - rcClient.top) - pContainer->m_statusBarHeight - (pContainer->m_tBorder_outer_top + pContainer->m_tBorder_outer_bottom) - rebarHeight); - - AdjustTabClientRect(pContainer, &rcClient); - - BOOL sizeChanged = (((rcClient.right - rcClient.left) != pContainer->m_preSIZE.cx) || ((rcClient.bottom - rcClient.top) != pContainer->m_preSIZE.cy)); - if (sizeChanged) { - pContainer->m_preSIZE.cx = rcClient.right - rcClient.left; - pContainer->m_preSIZE.cy = rcClient.bottom - rcClient.top; - } - - // we care about all client sessions, but we really resize only the active tab (hwndActive) - // we tell inactive tabs to resize theirselves later when they get activated (DM_CHECKSIZE - // just queues a resize request) - int nCount = TabCtrl_GetItemCount(hwndTab); - - for (int i = 0; i < nCount; i++) { - HWND hDlg = GetTabWindow(hwndTab, i); - if (hDlg == pContainer->m_hwndActive) { - SetWindowPos(hDlg, nullptr, rcClient.left, rcClient.top, (rcClient.right - rcClient.left), (rcClient.bottom - rcClient.top), - SWP_NOSENDCHANGING | SWP_NOACTIVATE/*|SWP_NOCOPYBITS*/); - if (!pContainer->m_bSizingLoop && sizeChanged) { - dat = (CMsgDialog*)GetWindowLongPtr(pContainer->m_hwndActive, GWLP_USERDATA); - if (dat) - dat->DM_ScrollToBottom(0, 1); - } - } - else if (sizeChanged) - SendMessage(hDlg, DM_CHECKSIZE, 0, 0); - } - pContainer->m_pSideBar->scrollIntoView(); - - if (!M.isAero()) { // aero mode uses buffered paint, no forced redraw needed - RedrawWindow(hwndTab, nullptr, nullptr, RDW_INVALIDATE | (pContainer->m_bSizingLoop ? RDW_ERASE : 0)); - RedrawWindow(hwndDlg, nullptr, nullptr, (CSkin::m_skinEnabled ? RDW_FRAME : 0) | RDW_INVALIDATE | ((pContainer->m_bSizingLoop || wParam == SIZE_RESTORED) ? RDW_ERASE : 0)); - } - - if (pContainer->m_hwndStatus) - InvalidateRect(pContainer->m_hwndStatus, nullptr, FALSE); - - if ((CSkin::m_bClipBorder != 0 || CSkin::m_bRoundedCorner) && CSkin::m_frameSkins) { - HRGN rgn; - int clip = CSkin::m_bClipBorder; - - RECT rcWindow; - GetWindowRect(hwndDlg, &rcWindow); - - if (CSkin::m_bRoundedCorner) - rgn = CreateRoundRectRgn(clip, clip, (rcWindow.right - rcWindow.left) - clip + 1, - (rcWindow.bottom - rcWindow.top) - clip + 1, CSkin::m_bRoundedCorner + clip, CSkin::m_bRoundedCorner + clip); - else - rgn = CreateRectRgn(clip, clip, (rcWindow.right - rcWindow.left) - clip, (rcWindow.bottom - rcWindow.top) - clip); - SetWindowRgn(hwndDlg, rgn, TRUE); - } - else if (CSkin::m_frameSkins) - SetWindowRgn(hwndDlg, nullptr, TRUE); - } + else + pContainer->Resize(wParam == SIZE_RESTORED, LOWORD(lParam)); break; case WM_NOTIFY: @@ -1120,7 +1212,7 @@ panel_found: switch (((LPNMHDR)lParam)->code) { case TCN_SELCHANGE: - if (HWND hDlg = GetTabWindow(hwndTab, TabCtrl_GetCurSel(hwndTab))) { + if (HWND hDlg = GetTabWindow(pContainer->m_hwndTabs, TabCtrl_GetCurSel(pContainer->m_hwndTabs))) { if (hDlg != pContainer->m_hwndActive) if (pContainer->m_hwndActive && IsWindow(pContainer->m_hwndActive)) ShowWindow(pContainer->m_hwndActive, SW_HIDE); @@ -1131,7 +1223,7 @@ panel_found: if (!IsIconic(hwndDlg)) SetFocus(pContainer->m_hwndActive); } - SendMessage(hwndTab, EM_VALIDATEBOTTOM, 0, 0); + SendMessage(pContainer->m_hwndTabs, EM_VALIDATEBOTTOM, 0, 0); return 0; // tooltips @@ -1144,7 +1236,7 @@ panel_found: HWND hDlg = nullptr; dat = nullptr; if (((LPNMHDR)lParam)->idFrom == IDC_MSGTABS) { - hDlg = GetTabWindow(hwndTab, GetTabItemFromMouse(hwndTab, &pt)); + hDlg = GetTabWindow(pContainer->m_hwndTabs, GetTabItemFromMouse(pContainer->m_hwndTabs, &pt)); if (hDlg && IsWindow(hDlg)) dat = (CMsgDialog*)GetWindowLongPtr(hDlg, GWLP_USERDATA); } @@ -1179,7 +1271,7 @@ panel_found: break; case ID_TABMENU_CLOSEOTHERTABS: if (dat) - CloseOtherTabs(hwndTab, *dat); + CloseOtherTabs(pContainer->m_hwndTabs, *dat); break; case ID_TABMENU_SAVETABPOSITION: if (dat) @@ -1197,7 +1289,7 @@ panel_found: } break; case ID_TABMENU_ATTACHTOCONTAINER: - hDlg = GetTabWindow(hwndTab, GetTabItemFromMouse(hwndTab, &pt)); + hDlg = GetTabWindow(pContainer->m_hwndTabs, GetTabItemFromMouse(pContainer->m_hwndTabs, &pt)); if (hDlg) CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_SELECTCONTAINER), hwndDlg, SelectContainerDlgProc, (LPARAM)hDlg); break; @@ -1209,7 +1301,7 @@ panel_found: SendMessage(hwndDlg, WM_CLOSE, 0, 0); break; } - InvalidateRect(hwndTab, nullptr, FALSE); + InvalidateRect(pContainer->m_hwndTabs, nullptr, FALSE); return 1; } break; @@ -1422,7 +1514,7 @@ panel_found: break; case WM_ENTERSIZEMOVE: - GetClientRect(hwndTab, &rc); + GetClientRect(pContainer->m_hwndTabs, &rc); { SIZE sz; sz.cx = rc.right - rc.left; @@ -1433,7 +1525,7 @@ panel_found: break; case WM_EXITSIZEMOVE: - GetClientRect(hwndTab, &rc); + GetClientRect(pContainer->m_hwndTabs, &rc); if (!((rc.right - rc.left) == pContainer->m_oldSize.cx && (rc.bottom - rc.top) == pContainer->m_oldSize.cy)) { dat = (CMsgDialog*)GetWindowLongPtr(pContainer->m_hwndActive, GWLP_USERDATA); if (dat) @@ -1456,12 +1548,12 @@ panel_found: MINMAXINFO *mmi = (MINMAXINFO *)lParam; mmi->ptMinTrackSize.x = 275; mmi->ptMinTrackSize.y = 130; - GetClientRect(hwndTab, &rc); + GetClientRect(pContainer->m_hwndTabs, &rc); if (pContainer->m_hwndActive) // at container creation time, there is no hwndActive yet.. GetClientRect(pContainer->m_hwndActive, &rcClient); GetWindowRect(hwndDlg, &rcWindow); pt.y = rc.top; - TabCtrl_AdjustRect(hwndTab, FALSE, &rc); + TabCtrl_AdjustRect(pContainer->m_hwndTabs, FALSE, &rc); // uChildMinHeight holds the min height for the client window only // so let's add the container's vertical padding (title bar, tab bar, // window border, status bar) to this value @@ -1509,7 +1601,7 @@ panel_found: if (wParam == TIMERID_HEARTBEAT) { if (GetForegroundWindow() != hwndDlg && (pContainer->m_pSettings->autoCloseSeconds > 0) && !pContainer->m_bHidden) { BOOL fResult = TRUE; - BroadCastContainer(pContainer, DM_CHECKAUTOHIDE, (WPARAM)pContainer->m_pSettings->autoCloseSeconds, (LPARAM)&fResult); + pContainer->BroadCastContainer(DM_CHECKAUTOHIDE, (WPARAM)pContainer->m_pSettings->autoCloseSeconds, (LPARAM)&fResult); if (fResult && nullptr == pContainer->m_hWndOptions) PostMessage(hwndDlg, WM_CLOSE, 1, 0); @@ -1589,7 +1681,7 @@ panel_found: break; if (LOWORD(wParam == WA_INACTIVE)) - BroadCastContainer(pContainer, DM_CHECKINFOTIP, wParam, lParam); + pContainer->BroadCastContainer(DM_CHECKINFOTIP, wParam, lParam); if (LOWORD(wParam == WA_INACTIVE) && (HWND)lParam != PluginConfig.g_hwndHotkeyHandler && GetParent((HWND)lParam) != hwndDlg) { BOOL fTransAllowed = !CSkin::m_skinEnabled || IsWinVerVistaPlus(); @@ -1603,7 +1695,7 @@ panel_found: if (LOWORD(wParam) != WA_ACTIVE) { pContainer->m_pMenuBar->Cancel(); - if (HWND hDlg = GetTabWindow(hwndTab, TabCtrl_GetCurSel(hwndTab))) + if (HWND hDlg = GetTabWindow(pContainer->m_hwndTabs, TabCtrl_GetCurSel(pContainer->m_hwndTabs))) SendMessage(hDlg, WM_ACTIVATE, WA_INACTIVE, 0); break; } @@ -1612,14 +1704,14 @@ panel_found: if (pContainer != nullptr) { BOOL fTransAllowed = !CSkin::m_skinEnabled || IsWinVerVistaPlus(); - FlashContainer(pContainer, 0, 0); + pContainer->FlashContainer(0, 0); pContainer->m_dwFlashingStarted = 0; pLastActiveContainer = pContainer; if (pContainer->m_flags.m_bDeferredTabSelect) { pContainer->m_flags.m_bDeferredTabSelect = false; SendMessage(hwndDlg, WM_SYSCOMMAND, SC_RESTORE, 0); - NMHDR nmhdr = { hwndTab, IDC_MSGTABS, TCN_SELCHANGE }; + NMHDR nmhdr = { pContainer->m_hwndTabs, IDC_MSGTABS, TCN_SELCHANGE }; SendMessage(hwndDlg, WM_NOTIFY, 0, (LPARAM)&nmhdr); // do it via a WM_NOTIFY / TCN_SELCHANGE to simulate user-activation } if (pContainer->m_flags.m_bDeferredResize) { @@ -1641,7 +1733,7 @@ panel_found: } } - HWND hDlg = GetTabWindow(hwndTab, TabCtrl_GetCurSel(hwndTab)); + HWND hDlg = GetTabWindow(pContainer->m_hwndTabs, TabCtrl_GetCurSel(pContainer->m_hwndTabs)); if (pContainer->m_flags.m_bDeferredConfigure && hDlg) { pContainer->m_flags.m_bDeferredConfigure = false; pContainer->m_hwndActive = hDlg; @@ -1661,8 +1753,8 @@ panel_found: case WM_MOUSEMOVE: // wine: fix for erase/paint tab on mouse enter/leave tab. GetCursorPos(&pt); - ScreenToClient(hwndTab, &pt); - SendMessage(hwndTab, WM_MOUSEMOVE, wParam, (LPARAM)&pt); + ScreenToClient(pContainer->m_hwndTabs, &pt); + SendMessage(pContainer->m_hwndTabs, WM_MOUSEMOVE, wParam, (LPARAM)&pt); break; case WM_PAINT: @@ -1782,11 +1874,27 @@ panel_found: GetClientRect(hwndDlg, pRect); else CopyRect(pRect, &pContainer->m_rcSaved); - AdjustTabClientRect(pContainer, pRect); + pContainer->AdjustTabClientRect(*pRect); } } return 0; + case WM_MOUSEWHEEL: + GetCursorPos(&pt); + + if (pContainer->m_flags.m_bSideBar) { + RECT rc1; + GetWindowRect(GetDlgItem(pContainer->m_hwnd, IDC_SIDEBARUP), &rc); + GetWindowRect(GetDlgItem(pContainer->m_hwnd, IDC_SIDEBARDOWN), &rc1); + rc.bottom = rc1.bottom; + if (PtInRect(&rc, pt)) { + short amount = (short)(HIWORD(wParam)); + SendMessage(pContainer->m_hwnd, WM_COMMAND, MAKELONG(amount > 0 ? IDC_SIDEBARUP : IDC_SIDEBARDOWN, 0), IDC_SRMM_MESSAGE); + return 0; + } + } + break; + case WM_DESTROY: pContainer->m_hwnd = nullptr; pContainer->m_hwndActive = nullptr; @@ -1828,18 +1936,18 @@ panel_found: pContainer->m_bHidden = true; } else { - if (TabCtrl_GetItemCount(hwndTab) > 1) { + if (TabCtrl_GetItemCount(pContainer->m_hwndTabs) > 1) { LRESULT res = CWarning::show(CWarning::WARN_CLOSEWINDOW, MB_YESNOCANCEL | MB_ICONQUESTION); if (IDNO == res || IDCANCEL == res) break; } // dont ask if container is empty (no tabs) - if (lParam == 0 && TabCtrl_GetItemCount(hwndTab) > 0) { - int clients = TabCtrl_GetItemCount(hwndTab), iOpenJobs = 0; + if (lParam == 0 && TabCtrl_GetItemCount(pContainer->m_hwndTabs) > 0) { + int clients = TabCtrl_GetItemCount(pContainer->m_hwndTabs), iOpenJobs = 0; for (int i = 0; i < clients; i++) { - HWND hDlg = GetTabWindow(hwndTab, i); + HWND hDlg = GetTabWindow(pContainer->m_hwndTabs, i); if (hDlg && IsWindow(hDlg)) SendMessage(hDlg, DM_CHECKQUEUEFORCLOSE, 0, (LPARAM)&iOpenJobs); } @@ -1861,12 +1969,12 @@ panel_found: wp.length = sizeof(wp); if (GetWindowPlacement(hwndDlg, &wp) != 0) { if (pContainer->m_isCloned && pContainer->m_hContactFrom != 0) { - HWND hDlg = GetTabWindow(hwndTab, TabCtrl_GetCurSel(hwndTab)); + HWND hDlg = GetTabWindow(pContainer->m_hwndTabs, TabCtrl_GetCurSel(pContainer->m_hwndTabs)); SendMessage(hDlg, DM_QUERYHCONTACT, 0, (LPARAM)&hContact); db_set_b(hContact, SRMSGMOD_T, "splitmax", (BYTE)((wp.showCmd == SW_SHOWMAXIMIZED) ? 1 : 0)); - for (int i = 0; i < TabCtrl_GetItemCount(hwndTab); i++) { - if (hDlg = GetTabWindow(hwndTab, i)) { + for (int i = 0; i < TabCtrl_GetItemCount(pContainer->m_hwndTabs); i++) { + if (hDlg = GetTabWindow(pContainer->m_hwndTabs, i)) { SendMessage(hDlg, DM_QUERYHCONTACT, 0, (LPARAM)&hContact); db_set_dw(hContact, SRMSGMOD_T, "splitx", wp.rcNormalPosition.left); db_set_dw(hContact, SRMSGMOD_T, "splity", wp.rcNormalPosition.top); @@ -1894,8 +2002,8 @@ panel_found: // clear temp flags which should NEVER be saved... if (pContainer->m_isCloned && pContainer->m_hContactFrom != 0) { pContainer->m_flags.m_bDeferredConfigure = pContainer->m_flags.m_bCreateMinimized = pContainer->m_flags.m_bDeferredResize = pContainer->m_flags.m_bCreateCloned = false; - for (int i = 0; i < TabCtrl_GetItemCount(hwndTab); i++) { - if (HWND hDlg = GetTabWindow(hwndTab, i)) { + for (int i = 0; i < TabCtrl_GetItemCount(pContainer->m_hwndTabs); i++) { + if (HWND hDlg = GetTabWindow(pContainer->m_hwndTabs, i)) { SendMessage(hDlg, DM_QUERYHCONTACT, 0, (LPARAM)&hContact); char szCName[40]; @@ -2118,62 +2226,6 @@ static TContainerData* TSAPI RemoveContainerFromList(TContainerData *pContainer) return nullptr; } -// calls the TabCtrl_AdjustRect to calculate the "real" client area of the tab. -// also checks for the option "hide tabs when only one tab open" and adjusts -// geometry if necessary -// rc is the RECT obtained by GetClientRect(hwndTab) - -void TSAPI AdjustTabClientRect(TContainerData *pContainer, RECT *rc) -{ - HWND hwndTab = GetDlgItem(pContainer->m_hwnd, IDC_MSGTABS); - DWORD tBorder = pContainer->m_tBorder; - DWORD dwStyle = GetWindowLongPtr(hwndTab, GWL_STYLE); - - RECT rcTab, rcTabOrig; - GetClientRect(hwndTab, &rcTab); - if (!pContainer->m_flags.m_bSideBar && (pContainer->m_iChilds > 1 || !pContainer->m_flags.m_bHideTabs)) { - rcTabOrig = rcTab; - TabCtrl_AdjustRect(hwndTab, FALSE, &rcTab); - DWORD dwTopPad = rcTab.top - rcTabOrig.top; - - rc->left += tBorder; - rc->right -= tBorder; - - if (dwStyle & TCS_BUTTONS) { - if (pContainer->m_flags.m_bTabsBottom) { - int nCount = TabCtrl_GetItemCount(hwndTab); - if (nCount > 0) { - RECT rcItem; - TabCtrl_GetItemRect(hwndTab, nCount - 1, &rcItem); - rc->bottom = rcItem.top; - } - } - else { - rc->top += (dwTopPad - 2); - rc->bottom = rcTabOrig.bottom; - } - } - else { - if (pContainer->m_flags.m_bTabsBottom) - rc->bottom = rcTab.bottom + 2; - else { - rc->top += (dwTopPad - 2); - rc->bottom = rcTabOrig.bottom; - } - } - - rc->top += tBorder; - rc->bottom -= tBorder; - } - else { - rc->bottom = rcTab.bottom; - rc->top = rcTab.top; - } - rc->right -= (pContainer->m_tBorder_outer_left + pContainer->m_tBorder_outer_right); - if (pContainer->m_pSideBar->isVisible()) - rc->right -= pContainer->m_pSideBar->getWidth(); -} - // retrieve the container name for the given contact handle. // if none is assigned, return the name of the default container @@ -2277,13 +2329,14 @@ HMENU TSAPI BuildContainerMenu() return hMenu; } +///////////////////////////////////////////////////////////////////////////////////////// // flashes the container // iMode != 0: turn on flashing // iMode == 0: turn off flashing -void TSAPI FlashContainer(TContainerData *pContainer, int iMode, int iCount) +void TContainerData::FlashContainer(int iMode, int iCount) { - if (pContainer->m_flags.m_bNoFlash) // container should never flash + if (m_flags.m_bNoFlash) // container should never flash return; FLASHWINFO fwi; @@ -2292,7 +2345,7 @@ void TSAPI FlashContainer(TContainerData *pContainer, int iMode, int iCount) if (iMode) { fwi.dwFlags = FLASHW_ALL; - if (pContainer->m_flags.m_bFlashAlways) + if (m_flags.m_bFlashAlways) fwi.dwFlags |= FLASHW_TIMER; else fwi.uCount = (iCount == 0) ? M.GetByte("nrflash", 4) : iCount; @@ -2301,55 +2354,11 @@ void TSAPI FlashContainer(TContainerData *pContainer, int iMode, int iCount) } else fwi.dwFlags = FLASHW_STOP; - fwi.hwnd = pContainer->m_hwnd; - pContainer->m_dwFlashingStarted = GetTickCount(); + fwi.hwnd = m_hwnd; + m_dwFlashingStarted = GetTickCount(); FlashWindowEx(&fwi); } -void TSAPI ReflashContainer(TContainerData *pContainer) -{ - DWORD dwStartTime = pContainer->m_dwFlashingStarted; - - if (pContainer->IsActive()) // dont care about active windows - return; - - if (pContainer->m_flags.m_bNoFlash || pContainer->m_dwFlashingStarted == 0) - return; // dont care about containers which should never flash - - if (pContainer->m_flags.m_bFlashAlways) - FlashContainer(pContainer, 1, 0); - else { - // recalc the remaining flashes - DWORD dwInterval = M.GetDword("flashinterval", 1000); - int iFlashesElapsed = (GetTickCount() - dwStartTime) / dwInterval; - DWORD dwFlashesDesired = M.GetByte("nrflash", 4); - if (iFlashesElapsed < (int)dwFlashesDesired) - FlashContainer(pContainer, 1, dwFlashesDesired - iFlashesElapsed); - else { - BOOL isFlashed = FlashWindow(pContainer->m_hwnd, TRUE); - if (!isFlashed) - FlashWindow(pContainer->m_hwnd, TRUE); - } - } - pContainer->m_dwFlashingStarted = dwStartTime; -} - -// broadcasts a message to all child windows (tabs/sessions) - -void TSAPI BroadCastContainer(const TContainerData *pContainer, UINT message, WPARAM wParam, LPARAM lParam) -{ - if (pContainer == nullptr) - return; - HWND hwndTab = GetDlgItem(pContainer->m_hwnd, IDC_MSGTABS); - - int nCount = TabCtrl_GetItemCount(hwndTab); - for (int i = 0; i < nCount; i++) { - HWND hDlg = GetTabWindow(hwndTab, i); - if (IsWindow(hDlg)) - SendMessage(hDlg, message, wParam, lParam); - } -} - void TSAPI CloseAllContainers() { bool fOldHideSetting = PluginConfig.m_bHideOnClose; diff --git a/plugins/TabSRMM/src/containeroptions.cpp b/plugins/TabSRMM/src/containeroptions.cpp index 4c4ed28ad7..f3a85edc2c 100644 --- a/plugins/TabSRMM/src/containeroptions.cpp +++ b/plugins/TabSRMM/src/containeroptions.cpp @@ -42,7 +42,7 @@ static void ReloadGlobalContainerSettings(bool fForceReconfig) p->Configure(); else SendMessage(p->m_hwnd, WM_SIZE, 0, 1); - BroadCastContainer(p, DM_SETINFOPANEL, 0, 0); + p->BroadCastContainer(DM_SETINFOPANEL, 0, 0); } } } @@ -62,7 +62,7 @@ void TContainerData::ApplySetting(bool fForceResize) if (fForceResize) SendMessage(m_hwnd, WM_SIZE, 0, 1); - BroadCastContainer(this, WM_CBD_UPDATED, 0, 0); + BroadCastContainer(WM_CBD_UPDATED, 0, 0); } ///////////////////////////////////////////////////////////////////////////////////////// @@ -314,7 +314,7 @@ INT_PTR CALLBACK DlgProcContainerOptions(HWND hwndDlg, UINT msg, WPARAM wParam, } pContainer->Configure(); - BroadCastContainer(pContainer, DM_SETINFOPANEL, 0, 0); + pContainer->BroadCastContainer(DM_SETINFOPANEL, 0, 0); ShowWindow(pContainer->m_hwnd, SW_HIDE); { diff --git a/plugins/TabSRMM/src/controls.cpp b/plugins/TabSRMM/src/controls.cpp index fffb0411e7..76b47c9dcf 100644 --- a/plugins/TabSRMM/src/controls.cpp +++ b/plugins/TabSRMM/src/controls.cpp @@ -48,13 +48,13 @@ static int resetLP(WPARAM, LPARAM, LPARAM obj) return 0; } -CMenuBar::CMenuBar(HWND hwndParent, const TContainerData *pContainer) +CMenuBar::CMenuBar(const TContainerData *pContainer) { m_pContainer = const_cast(pContainer); if (m_MimIcon == nullptr) { - HDC hdc = ::GetDC(m_pContainer->m_hwnd); - HANDLE hIcon = Skin_GetIconHandle(SKINICON_OTHER_MIRANDA); + HDC hdc = ::GetDC(m_pContainer->m_hwnd); + HANDLE hIcon = Skin_GetIconHandle(SKINICON_OTHER_MIRANDA); HDC hdcTemp = ::CreateCompatibleDC(hdc); @@ -71,7 +71,7 @@ CMenuBar::CMenuBar(HWND hwndParent, const TContainerData *pContainer) m_MimIconRefCount++; m_hwndToolbar = ::CreateWindowEx(WS_EX_TOOLWINDOW, TOOLBARCLASSNAME, nullptr, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE | TBSTYLE_FLAT | TBSTYLE_TRANSPARENT | TBSTYLE_LIST |/*CCS_NOPARENTALIGN|*/CCS_NODIVIDER | CCS_TOP, - 0, 0, 0, 0, hwndParent, nullptr, g_plugin.getInst(), nullptr); + 0, 0, 0, 0, m_pContainer->m_hwnd, nullptr, g_plugin.getInst(), nullptr); ::SendMessage(m_hwndToolbar, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0); diff --git a/plugins/TabSRMM/src/controls.h b/plugins/TabSRMM/src/controls.h index ee9c8df8fe..62fc0f4d6b 100644 --- a/plugins/TabSRMM/src/controls.h +++ b/plugins/TabSRMM/src/controls.h @@ -36,7 +36,7 @@ public: NR_BUTTONS = 8 }; - CMenuBar(HWND hwndParent, const TContainerData *pContainer); + CMenuBar(const TContainerData *pContainer); ~CMenuBar(); const RECT& getClientRect(); diff --git a/plugins/TabSRMM/src/functions.h b/plugins/TabSRMM/src/functions.h index c6e08bc581..d0b8086676 100644 --- a/plugins/TabSRMM/src/functions.h +++ b/plugins/TabSRMM/src/functions.h @@ -72,7 +72,6 @@ void TSAPI HandleMenuEntryFromhContact(MCONTACT iSelection); HWND TSAPI CreateNewTabForContact(TContainerData *pContainer, MCONTACT hContact, bool bActivateTAb, bool bPopupContainer, bool bWantPopup, MEVENT hdbEvent = 0, bool bIsWchar = false, const char *pszInitialText = nullptr); int TSAPI ActivateTabFromHWND(HWND hwndTab, HWND hwnd); -void TSAPI FlashContainer(TContainerData *pContainer, int iMode, int iNum); void TSAPI CreateImageList(bool bInitial); TContainerData* TSAPI FindMatchingContainer(const wchar_t *szName); @@ -84,16 +83,12 @@ HWND TSAPI GetTabWindow(HWND hwndTab, int idx); int TSAPI GetTabItemFromMouse(HWND hwndTab, POINT *pt); void TSAPI CloseOtherTabs(HWND hwndTab, CMsgDialog &dat); int TSAPI ActivateTabFromHWND(HWND hwndTab, HWND hwnd); -void TSAPI AdjustTabClientRect(TContainerData *pContainer, RECT *rc); -void TSAPI ReflashContainer(TContainerData *pContainer); void TSAPI CloseAllContainers(); void TSAPI DeleteContainer(int iIndex); void TSAPI RenameContainer(int iIndex, const wchar_t *newName); void TSAPI GetContainerNameForContact(MCONTACT hContact, wchar_t *szName, int iNameLen); HMENU TSAPI BuildContainerMenu(); -void TSAPI BroadCastContainer(const TContainerData *pContainer, UINT message, WPARAM wParam, LPARAM lParam); -void TSAPI SetAeroMargins(TContainerData *pContainer); int TSAPI MessageWindowOpened(MCONTACT hContact, HWND hwnd); diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp index c51de0aa12..724b062375 100644 --- a/plugins/TabSRMM/src/generic_msghandlers.cpp +++ b/plugins/TabSRMM/src/generic_msghandlers.cpp @@ -162,7 +162,7 @@ bool CMsgDialog::DM_GenericHotkeysCheck(MSG *message) return true; case TABSRMM_HK_CLOSE_OTHER: - CloseOtherTabs(GetDlgItem(m_pContainer->m_hwnd, IDC_MSGTABS), *this); + CloseOtherTabs(m_pContainer->m_hwndTabs, *this); return true; } return false; @@ -757,21 +757,11 @@ LRESULT CMsgDialog::DM_MouseWheelHandler(WPARAM wParam, LPARAM lParam) POINT pt; GetCursorPos(&pt); - RECT rc, rc1; + RECT rc; GetWindowRect(m_message.GetHwnd(), &rc); if (PtInRect(&rc, pt)) return 1; - if (m_pContainer->m_flags.m_bSideBar) { - GetWindowRect(GetDlgItem(m_pContainer->m_hwnd, IDC_SIDEBARUP), &rc); - GetWindowRect(GetDlgItem(m_pContainer->m_hwnd, IDC_SIDEBARDOWN), &rc1); - rc.bottom = rc1.bottom; - if (PtInRect(&rc, pt)) { - short amount = (short)(HIWORD(wParam)); - SendMessage(m_pContainer->m_hwnd, WM_COMMAND, MAKELONG(amount > 0 ? IDC_SIDEBARUP : IDC_SIDEBARDOWN, 0), IDC_SRMM_MESSAGE); - return 0; - } - } if (isChat()) { // scroll nick list by just hovering it RECT rcNicklist; GetWindowRect(m_nickList.GetHwnd(), &rcNicklist); @@ -795,9 +785,8 @@ LRESULT CMsgDialog::DM_MouseWheelHandler(WPARAM wParam, LPARAM lParam) return 0; } - HWND hwndTab = GetDlgItem(m_pContainer->m_hwnd, IDC_MSGTABS); - if (GetTabItemFromMouse(hwndTab, &pt) != -1) { - SendMessage(hwndTab, WM_MOUSEWHEEL, wParam, -1); + if (GetTabItemFromMouse(m_pContainer->m_hwndTabs, &pt) != -1) { + SendMessage(m_pContainer->m_hwndTabs, WM_MOUSEWHEEL, wParam, -1); return 0; } return 1; @@ -964,7 +953,7 @@ void CMsgDialog::DM_Typing(bool fForceOff) else m_pContainer->UpdateTitle(0, dat_active); if (!m_pContainer->m_flags.m_bNoFlash && PluginConfig.m_FlashOnMTN) - ReflashContainer(m_pContainer); + m_pContainer->ReflashContainer(); } } else if (m_bShowTyping == 2) { @@ -988,7 +977,7 @@ void CMsgDialog::DM_Typing(bool fForceOff) SetWindowText(hwndContainer, m_wszStatusBar); m_pContainer->m_flags.m_bNeedsUpdateTitle = true; if (!m_pContainer->m_flags.m_bNoFlash && PluginConfig.m_FlashOnMTN) - ReflashContainer(m_pContainer); + m_pContainer->ReflashContainer(); } if (m_pContainer->m_hwndActive != m_hwnd) { @@ -1193,7 +1182,7 @@ void CMsgDialog::DM_EventAdded(WPARAM hContact, LPARAM lParam) if (!bDisableNotify && !bIsStatusChangeEvent) if (!IsActive() && !(dbei.flags & DBEF_SENT)) { if (!m_pContainer->m_flags.m_bNoFlash && !m_pContainer->IsActive()) - FlashContainer(m_pContainer, 1, 0); + m_pContainer->FlashContainer(1, 0); m_pContainer->SetIcon(this, Skin_LoadIcon(SKINICON_EVENT_MESSAGE)); m_pContainer->m_flags.m_bNeedsUpdateTitle = true; } diff --git a/plugins/TabSRMM/src/hotkeyhandler.cpp b/plugins/TabSRMM/src/hotkeyhandler.cpp index 36f00dd3bb..dab38a84a2 100644 --- a/plugins/TabSRMM/src/hotkeyhandler.cpp +++ b/plugins/TabSRMM/src/hotkeyhandler.cpp @@ -356,7 +356,7 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP TContainerData *pContainer = nullptr; SendMessage(hWnd, DM_QUERYCONTAINER, 0, (LPARAM)&pContainer); if (pContainer) { - int iTabs = TabCtrl_GetItemCount(GetDlgItem(pContainer->m_hwnd, IDC_MSGTABS)); + int iTabs = TabCtrl_GetItemCount(pContainer->m_hwndTabs); if (iTabs == 1) SendMessage(pContainer->m_hwnd, WM_CLOSE, 0, 1); else @@ -394,7 +394,7 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP for (TContainerData *pCont = pFirstContainer; pCont; pCont = pCont->pNext) { if (bNewAero) - SetAeroMargins(pCont); + pCont->SetAeroMargins(); else { MARGINS m = { 0 }; if (M.m_pfnDwmExtendFrameIntoClientArea) @@ -431,8 +431,8 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP ReloadTabConfig(); for (TContainerData *pCont = pFirstContainer; pCont; pCont = pCont->pNext) { - SendDlgItemMessage(pCont->m_hwnd, IDC_MSGTABS, EM_THEMECHANGED, 0, 0); - BroadCastContainer(pCont, EM_THEMECHANGED, 0, 0); + SendMessage(pCont->m_hwndTabs, EM_THEMECHANGED, 0, 0); + pCont->BroadCastContainer(EM_THEMECHANGED, 0, 0); } break; diff --git a/plugins/TabSRMM/src/infopanel.cpp b/plugins/TabSRMM/src/infopanel.cpp index 8249f67bf9..21a304db0f 100644 --- a/plugins/TabSRMM/src/infopanel.cpp +++ b/plugins/TabSRMM/src/infopanel.cpp @@ -150,7 +150,7 @@ void CInfoPanel::setHeight(LONG newHeight, bool fBroadcast) if (!m_dat->m_pContainer->m_pSettings->fPrivate) Srmm_Broadcast(DM_SETINFOPANEL, (WPARAM)m_dat, (LPARAM)newHeight); else - ::BroadCastContainer(m_dat->m_pContainer, DM_SETINFOPANEL, (WPARAM)m_dat, (LPARAM)newHeight); + m_dat->m_pContainer->BroadCastContainer(DM_SETINFOPANEL, (WPARAM)m_dat, (LPARAM)newHeight); } saveHeight(); } @@ -204,7 +204,7 @@ void CInfoPanel::showHide() const ::SendMessage(hwndDlg, WM_SIZE, 0, 0); } - ::SetAeroMargins(m_dat->m_pContainer); + m_dat->m_pContainer->SetAeroMargins(); if (M.isAero()) ::InvalidateRect(GetParent(hwndDlg), nullptr, FALSE); m_dat->DM_ScrollToBottom(0, 1); @@ -1196,20 +1196,20 @@ INT_PTR CALLBACK CInfoPanel::ConfigDlgProc(HWND hwnd, UINT msg, WPARAM wParam, L if (!m_dat->m_pContainer->m_pSettings->fPrivate) Srmm_Broadcast(DM_SETINFOPANEL, (WPARAM)m_dat, (LPARAM)m_defaultHeight); else - ::BroadCastContainer(m_dat->m_pContainer, DM_SETINFOPANEL, (WPARAM)m_dat, (LPARAM)m_defaultHeight); + m_dat->m_pContainer->BroadCastContainer(DM_SETINFOPANEL, (WPARAM)m_dat, (LPARAM)m_defaultHeight); } else { if (!m_dat->m_pContainer->m_pSettings->fPrivate) Srmm_Broadcast(DM_SETINFOPANEL, (WPARAM)m_dat, 0); else - ::BroadCastContainer(m_dat->m_pContainer, DM_SETINFOPANEL, (WPARAM)m_dat, 0); + m_dat->m_pContainer->BroadCastContainer(DM_SETINFOPANEL, (WPARAM)m_dat, 0); } break; } if (m_height != lOldHeight) { ::SendMessage(m_dat->GetHwnd(), WM_SIZE, 0, 0); - ::SetAeroMargins(m_dat->m_pContainer); + m_dat->m_pContainer->SetAeroMargins(); ::RedrawWindow(m_dat->GetHwnd(), nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW); ::RedrawWindow(GetParent(m_dat->GetHwnd()), nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW); } diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index f8143743a6..bca0840c84 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -2409,7 +2409,7 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) DeleteDC(hdcMem); } if (!m_fLimitedUpdate) - SetAeroMargins(m_pContainer); + m_pContainer->SetAeroMargins(); } return 1; diff --git a/plugins/TabSRMM/src/msgdlgother.cpp b/plugins/TabSRMM/src/msgdlgother.cpp index 5c88229539..020af9a83d 100644 --- a/plugins/TabSRMM/src/msgdlgother.cpp +++ b/plugins/TabSRMM/src/msgdlgother.cpp @@ -2228,7 +2228,7 @@ void CMsgDialog::UpdateWindowState(UINT msg) m_bDividerSet = false; if (m_pContainer->m_dwFlashingStarted != 0) { - FlashContainer(m_pContainer, 0, 0); + m_pContainer->FlashContainer(0, 0); m_pContainer->m_dwFlashingStarted = 0; } diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp index dca0a1a8db..0496d68be4 100644 --- a/plugins/TabSRMM/src/msgdlgutils.cpp +++ b/plugins/TabSRMM/src/msgdlgutils.cpp @@ -225,7 +225,7 @@ void TSAPI HandleIconFeedback(CMsgDialog *dat, HICON iIcon) if (dat->m_pContainer->m_flags.m_bSideBar) dat->m_pContainer->m_pSideBar->updateSession(dat); else - TabCtrl_SetItem(GetDlgItem(dat->m_pContainer->m_hwnd, IDC_MSGTABS), dat->m_iTabID, &item); + TabCtrl_SetItem(dat->m_pContainer->m_hwndTabs, dat->m_iTabID, &item); } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/plugins/TabSRMM/src/msgoptions.cpp b/plugins/TabSRMM/src/msgoptions.cpp index 14e0f156dc..c75ceaa92f 100644 --- a/plugins/TabSRMM/src/msgoptions.cpp +++ b/plugins/TabSRMM/src/msgoptions.cpp @@ -478,9 +478,8 @@ public: ReloadTabConfig(); for (TContainerData* p = pFirstContainer; p; p = p->pNext) { - HWND hwndTab = GetDlgItem(p->m_hwnd, IDC_MSGTABS); - TabCtrl_SetPadding(hwndTab, xpad.GetPosition(), ypad.GetPosition()); - RedrawWindow(hwndTab, nullptr, nullptr, RDW_INVALIDATE | RDW_ERASE); + TabCtrl_SetPadding(p->m_hwndTabs, xpad.GetPosition(), ypad.GetPosition()); + ::RedrawWindow(p->m_hwndTabs, nullptr, nullptr, RDW_INVALIDATE | RDW_ERASE); } return true; } diff --git a/plugins/TabSRMM/src/msgs.cpp b/plugins/TabSRMM/src/msgs.cpp index 611299f6e5..ed1c11e543 100644 --- a/plugins/TabSRMM/src/msgs.cpp +++ b/plugins/TabSRMM/src/msgs.cpp @@ -242,7 +242,7 @@ int AvatarChanged(WPARAM wParam, LPARAM lParam) return 0; for (TContainerData *p = pFirstContainer; p; p = p->pNext) - BroadCastContainer(p, DM_UPDATEPICLAYOUT, wParam, lParam); + p->BroadCastContainer(DM_UPDATEPICLAYOUT, wParam, lParam); return 0; } @@ -252,7 +252,7 @@ int MyAvatarChanged(WPARAM wParam, LPARAM lParam) return 0; for (TContainerData *p = pFirstContainer; p; p = p->pNext) - BroadCastContainer(p, DM_MYAVATARCHANGED, wParam, lParam); + p->BroadCastContainer(DM_MYAVATARCHANGED, wParam, lParam); return 0; } @@ -271,8 +271,8 @@ int TSAPI ActivateExistingTab(TContainerData *pContainer, HWND hwndChild) NMHDR nmhdr = {}; nmhdr.code = TCN_SELCHANGE; - if (TabCtrl_GetItemCount(GetDlgItem(pContainer->m_hwnd, IDC_MSGTABS)) > 1 && !pContainer->m_flags.m_bDeferredTabSelect) { - TabCtrl_SetCurSel(GetDlgItem(pContainer->m_hwnd, IDC_MSGTABS), GetTabIndexFromHWND(GetDlgItem(pContainer->m_hwnd, IDC_MSGTABS), hwndChild)); + if (TabCtrl_GetItemCount(pContainer->m_hwndTabs) > 1 && !pContainer->m_flags.m_bDeferredTabSelect) { + TabCtrl_SetCurSel(pContainer->m_hwndTabs, GetTabIndexFromHWND(pContainer->m_hwndTabs, hwndChild)); SendMessage(pContainer->m_hwnd, WM_NOTIFY, 0, (LPARAM)&nmhdr); // just select the tab and let WM_NOTIFY do the rest } if (!dat->isChat()) @@ -290,7 +290,7 @@ int TSAPI ActivateExistingTab(TContainerData *pContainer, HWND hwndChild) // all tabs must re-check the layout on activation because adding a tab while // the container was hidden can make this necessary - BroadCastContainer(pContainer, DM_CHECKSIZE, 0, 0); + pContainer->BroadCastContainer(DM_CHECKSIZE, 0, 0); if (wp.showCmd == SW_SHOWMAXIMIZED) ShowWindow(pContainer->m_hwnd, SW_SHOWMAXIMIZED); else { @@ -349,18 +349,17 @@ HWND TSAPI CreateNewTabForContact(TContainerData *pContainer, MCONTACT hContact, else mir_snwprintf(tabtitle, L"%s", newcontactname); - HWND hwndTab = GetDlgItem(pContainer->m_hwnd, IDC_MSGTABS); // hide the active tab if (pContainer->m_hwndActive && bActivateTab) ShowWindow(pContainer->m_hwndActive, SW_HIDE); int iTabIndex_wanted = M.GetDword(hContact, "tabindex", pContainer->m_iChilds * 100); - int iCount = TabCtrl_GetItemCount(hwndTab); + int iCount = TabCtrl_GetItemCount(pContainer->m_hwndTabs); pContainer->m_iTabIndex = iCount; if (iCount > 0) { for (int i = iCount - 1; i >= 0; i--) { - HWND hwnd = GetTabWindow(hwndTab, i); + HWND hwnd = GetTabWindow(pContainer->m_hwndTabs, i); CMsgDialog *dat = (CMsgDialog*)GetWindowLongPtr(hwnd, GWLP_USERDATA); if (dat) { int relPos = M.GetDword(dat->m_hContact, "tabindex", i * 100); @@ -375,11 +374,11 @@ HWND TSAPI CreateNewTabForContact(TContainerData *pContainer, MCONTACT hContact, item.mask = TCIF_TEXT | TCIF_IMAGE; item.iImage = 0; item.cchTextMax = _countof(tabtitle); - int iTabId = TabCtrl_InsertItem(hwndTab, pContainer->m_iTabIndex, &item); + int iTabId = TabCtrl_InsertItem(pContainer->m_hwndTabs, pContainer->m_iTabIndex, &item); - SendMessage(hwndTab, EM_REFRESHWITHOUTCLIP, 0, 0); + SendMessage(pContainer->m_hwndTabs, EM_REFRESHWITHOUTCLIP, 0, 0); if (bActivateTab) - TabCtrl_SetCurSel(hwndTab, iTabId); + TabCtrl_SetCurSel(pContainer->m_hwndTabs, iTabId); CMsgDialog *pWindow = new CMsgDialog(IDD_MSGSPLITNEW, hContact); pWindow->m_iTabID = iTabId; @@ -391,7 +390,7 @@ HWND TSAPI CreateNewTabForContact(TContainerData *pContainer, MCONTACT hContact, pWindow->m_hDbEventFirst = hdbEvent; if (pszInitialText) pWindow->wszInitialText = (bIsUnicode) ? mir_wstrdup((const wchar_t*)pszInitialText) : mir_a2u(pszInitialText); - pWindow->SetParent(hwndTab); + pWindow->SetParent(pContainer->m_hwndTabs); pWindow->Create(); HWND hwndNew = pWindow->GetHwnd(); @@ -412,7 +411,7 @@ HWND TSAPI CreateNewTabForContact(TContainerData *pContainer, MCONTACT hContact, if (pContainer->m_flags.m_bNoFlash) pContainer->SetIcon(0, Skin_LoadIcon(SKINICON_EVENT_MESSAGE)); else - FlashContainer(pContainer, 1, 0); + pContainer->FlashContainer(1, 0); } } @@ -435,7 +434,7 @@ HWND TSAPI CreateNewTabForContact(TContainerData *pContainer, MCONTACT hContact, wp.length = sizeof(wp); GetWindowPlacement(pContainer->m_hwnd, &wp); - BroadCastContainer(pContainer, DM_CHECKSIZE, 0, 0); // make sure all tabs will re-check layout on activation + pContainer->BroadCastContainer(DM_CHECKSIZE, 0, 0); // make sure all tabs will re-check layout on activation if (wp.showCmd == SW_SHOWMAXIMIZED) ShowWindow(pContainer->m_hwnd, SW_SHOWMAXIMIZED); else { diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h index 3ad867b1ae..e009771481 100644 --- a/plugins/TabSRMM/src/msgs.h +++ b/plugins/TabSRMM/src/msgs.h @@ -213,14 +213,15 @@ struct TContainerData : public MZeroedObject TContainerFlags m_flags; TContainerFlagsEx m_flagsEx; - HWND m_hwndActive; // active message window - HWND m_hwnd; // the container handle - int m_iTabIndex; // next tab id + HWND m_hwndActive; // active message window + HWND m_hwnd; // the container handle + HWND m_hwndTabs; // tab control handle + int m_iTabIndex; // next tab id int m_iChilds; int m_iContainerIndex; bool m_bHidden; - HWND m_hwndTip; // tab - tooltips... - BOOL m_bDontSmartClose; // if set, do not search and select the next possible tab after closing one. + HWND m_hwndTip; // tab - tooltips... + BOOL m_bDontSmartClose; // if set, do not search and select the next possible tab after closing one. LONG m_uChildMinHeight; int m_tBorder; int m_tBorder_outer_left, m_tBorder_outer_right, m_tBorder_outer_top, m_tBorder_outer_bottom; @@ -229,8 +230,8 @@ struct TContainerData : public MZeroedObject HWND m_hwndStatus; int m_statusBarHeight; DWORD m_dwLastActivity; - int m_hIcon; // current window icon stick indicator - HICON m_hIconTaskbarOverlay; // contains a "sticky" taskbar overlay (e.g. new message icon) + int m_hIcon; // current window icon stick indicator + HICON m_hIconTaskbarOverlay; // contains a "sticky" taskbar overlay (e.g. new message icon) DWORD m_dwFlashingStarted; HWND m_hWndOptions; BOOL m_bSizingLoop; @@ -264,15 +265,22 @@ struct TContainerData : public MZeroedObject wchar_t m_wszName[CONTAINER_NAMELEN + 4]; // container name wchar_t m_szRelThemeFile[MAX_PATH], m_szAbsThemeFile[MAX_PATH]; + void AdjustTabClientRect(RECT &rc); void ApplySetting(bool fForceResize = false); + void BroadCastContainer(UINT message, WPARAM wParam, LPARAM lParam) const; void CloseTabByMouse(POINT *); void Configure(); + void FlashContainer(int iMode, int iCount); + void InitDialog(HWND); void InitRedraw(void); void LoadOverrideTheme(void); void LoadThemeDefaults(void); void QueryPending(); + void ReflashContainer(void); + void Resize(bool, int newWidth); void RestoreWindowPos(void); void SelectTab(int iCommand, int idx = 0); + void SetAeroMargins(void); void SetIcon(CMsgDialog *pDlg, HICON hIcon); void UpdateTabs(void); void UpdateTitle(MCONTACT, class CMsgDialog* = nullptr); diff --git a/plugins/TabSRMM/src/sendqueue.cpp b/plugins/TabSRMM/src/sendqueue.cpp index 67436718c8..e669e0dd54 100644 --- a/plugins/TabSRMM/src/sendqueue.cpp +++ b/plugins/TabSRMM/src/sendqueue.cpp @@ -377,7 +377,7 @@ void SendQueue::showErrorControls(CMsgDialog *dat, const int showCmd) const dat->m_hTabIcon = PluginConfig.g_iconErr; item.mask = TCIF_IMAGE; item.iImage = 0; - TabCtrl_SetItem(GetDlgItem(dat->m_pContainer->m_hwnd, IDC_MSGTABS), dat->m_iTabID, &item); + TabCtrl_SetItem(dat->m_pContainer->m_hwndTabs, dat->m_iTabID, &item); dat->m_bErrorState = true; } else { diff --git a/plugins/TabSRMM/src/sidebar.cpp b/plugins/TabSRMM/src/sidebar.cpp index 4a541e5763..b0618d0a23 100644 --- a/plugins/TabSRMM/src/sidebar.cpp +++ b/plugins/TabSRMM/src/sidebar.cpp @@ -28,7 +28,8 @@ #include "stdafx.h" -TSideBarLayout CSideBar::m_layouts[CSideBar::NR_LAYOUTS] = { +TSideBarLayout CSideBar::m_layouts[CSideBar::NR_LAYOUTS] = +{ { LPGENW("Like tabs, vertical text orientation"), 26, 30, @@ -134,19 +135,17 @@ void CSideBarButton::Show(const int showCmd) const */ const SIZE& CSideBarButton::measureItem() { - SIZE sz; - if (m_sideBarLayout->pfnMeasureItem) m_sideBarLayout->pfnMeasureItem(this); // use the current layout's function, if available, else use default else { HDC dc = ::GetDC(m_hwnd); - wchar_t tszLabel[255]; - HFONT oldFont = reinterpret_cast(::SelectObject(dc, ::GetStockObject(DEFAULT_GUI_FONT))); + wchar_t tszLabel[255]; wcsncpy_s(tszLabel, m_dat->m_wszTitle, _TRUNCATE); - ::GetTextExtentPoint32(dc, tszLabel, (int)mir_wstrlen(tszLabel), &sz); + SIZE sz; + ::GetTextExtentPoint32(dc, tszLabel, (int)mir_wstrlen(tszLabel), &sz); sz.cx += 28; if (m_dat->m_pContainer->m_flagsEx.m_bTabCloseButton) sz.cx += 20; @@ -161,25 +160,25 @@ const SIZE& CSideBarButton::measureItem() } return(m_sz); } + /** * Render the button item. Callback from the button window procedure * * @param ctl TSButtonCtrl *: pointer to the private button data structure * @param hdc HDC: device context for painting */ + void CSideBarButton::RenderThis(const HDC hdc) const { RECT rc; - LONG cx, cy; - bool fVertical = (m_sideBarLayout->dwFlags & CSideBar::SIDEBARLAYOUT_VERTICALORIENTATION) ? true : false; - HBITMAP hbmMem, hbmOld; - ::GetClientRect(m_hwnd, &rc); + bool bVertical = (m_sideBarLayout->dwFlags & CSideBar::SIDEBARLAYOUT_VERTICALORIENTATION) ? true : false; if (m_id == IDC_SIDEBARUP || m_id == IDC_SIDEBARDOWN) - fVertical = false; + bVertical = false; - if (fVertical) { + int cx, cy; + if (bVertical) { cx = rc.bottom; cy = rc.right; } @@ -190,15 +189,15 @@ void CSideBarButton::RenderThis(const HDC hdc) const HDC hdcMem = ::CreateCompatibleDC(hdc); - if (fVertical) { + HBITMAP hbmMem; + if (bVertical) { RECT rcFlipped = { 0, 0, cx, cy }; hbmMem = CSkin::CreateAeroCompatibleBitmap(rcFlipped, hdcMem); rc = rcFlipped; } else hbmMem = CSkin::CreateAeroCompatibleBitmap(rc, hdcMem); - hbmOld = reinterpret_cast(::SelectObject(hdcMem, hbmMem)); - + HBITMAP hbmOld = reinterpret_cast(::SelectObject(hdcMem, hbmMem)); HFONT hFontOld = reinterpret_cast(::SelectObject(hdcMem, ::GetStockObject(DEFAULT_GUI_FONT))); m_sideBarLayout->pfnBackgroundRenderer(hdcMem, &rc, this); @@ -206,12 +205,9 @@ void CSideBarButton::RenderThis(const HDC hdc) const ::SelectObject(hdcMem, hFontOld); - /* - * for vertical tabs, we did draw to a rotated rectangle, so we now must rotate the - * final bitmap back to it's original orientation - */ - - if (fVertical) { + // for vertical tabs, we did draw to a rotated rectangle, so we now must rotate the + // final bitmap back to it's original orientation + if (bVertical) { ::SelectObject(hdcMem, hbmOld); FIBITMAP *fib = FreeImage_CreateDIBFromHBITMAP(hbmMem); @@ -243,6 +239,7 @@ void CSideBarButton::RenderThis(const HDC hdc) const * @param hdc : target device context * @param rcItem : rectangle to render into */ + void CSideBarButton::renderIconAndNick(const HDC hdc, const RECT *rcItem) const { HICON hIcon; @@ -266,9 +263,7 @@ void CSideBarButton::renderIconAndNick(const HDC hdc, const RECT *rcItem) const rc.left += (iSize + 7); - /* - * draw the close button if enabled - */ + // draw the close button if enabled if (m_sideBar->getContainer()->m_flagsEx.m_bTabCloseButton) { if (m_sideBar->getHoveredClose() != this) CSkin::m_default_bf.SourceConstantAlpha = 150; @@ -427,10 +422,7 @@ void CSideBar::setVisible(bool fNewVisible) { m_isVisible = fNewVisible; - /* - * only needed on hiding. Layout() will do it when showing it - */ - + // only needed on hiding. Layout() will do it when showing it if (!m_isVisible) showAll(SW_HIDE); else { @@ -489,16 +481,12 @@ void CSideBar::removeAll() */ void CSideBar::populateAll() { - HWND hwndTab = ::GetDlgItem(m_pContainer->m_hwnd, IDC_MSGTABS); - if (hwndTab == nullptr) - return; - - int iItems = (int)TabCtrl_GetItemCount(hwndTab); + int iItems = (int)TabCtrl_GetItemCount(m_pContainer->m_hwndTabs); m_iTopButtons = 0; for (int i = 0; i < iItems; i++) { - HWND hDlg = GetTabWindow(hwndTab, i); + HWND hDlg = GetTabWindow(m_pContainer->m_hwndTabs, i); if (hDlg == 0 || !IsWindow(hDlg)) continue; @@ -623,7 +611,7 @@ void CSideBar::scrollIntoView(const CSideBarButton *item) fNeedLayout = true; } else { - if (spaceUsed > rc.bottom) { // partially or not at all visible at the bottom + if (spaceUsed > rc.bottom) { // partially or not at all visible at the bottom fNeedLayout = true; m_firstVisibleOffset = spaceUsed - rc.bottom; } @@ -868,6 +856,7 @@ LRESULT CALLBACK CSideBar::wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP HDC hdc = (HDC)wParam; RECT rc; ::GetClientRect(hwnd, &rc); + if (CSkin::m_skinEnabled) { CSkinItem *item = &SkinItems[ID_EXTBKSIDEBARBG]; @@ -877,8 +866,8 @@ LRESULT CALLBACK CSideBar::wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP CSkin::DrawItem(hdc, &rc, item); } else if (M.isAero() || M.isVSThemed()) { - HDC hdcMem; - HANDLE hbp = nullptr; + HDC hdcMem; + HANDLE hbp = nullptr; HBITMAP hbm, hbmOld; if (CMimAPI::m_haveBufferedPaint) { diff --git a/plugins/TabSRMM/src/themes.cpp b/plugins/TabSRMM/src/themes.cpp index 4d37fb3a8f..c201d1b42b 100644 --- a/plugins/TabSRMM/src/themes.cpp +++ b/plugins/TabSRMM/src/themes.cpp @@ -2356,7 +2356,7 @@ void CSkin::initAeroEffect() } for (TContainerData *p = pFirstContainer; p; p = p->pNext) { - InvalidateRect(GetDlgItem(p->m_hwnd, IDC_MSGTABS), nullptr, TRUE); + InvalidateRect(p->m_hwndTabs, nullptr, TRUE); InvalidateRect(p->m_hwnd, nullptr, TRUE); if (IsWindow(GetDlgItem(p->m_hwnd, 5000))) InvalidateRect(GetDlgItem(p->m_hwnd, 5000), nullptr, TRUE); diff --git a/plugins/TabSRMM/src/version.h b/plugins/TabSRMM/src/version.h index c77447f4ae..dfd5fdde8e 100644 --- a/plugins/TabSRMM/src/version.h +++ b/plugins/TabSRMM/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 3 #define __MINOR_VERSION 6 #define __RELEASE_NUM 0 -#define __BUILD_NUM 1 +#define __BUILD_NUM 2 #include -- cgit v1.2.3