From fae1ca5f044df291717616bc188ebccb69ec7848 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 30 Jan 2024 21:56:47 +0100 Subject: [PATCH] Tried to fix invisible tabs issue upon maximizing window but this doesn't seem to entirely work, submitting this to create a pull request that another developer can test --- src/TabBar.cpp | 30 +++++++++++++++++++++++++++--- src/TabBar.h | 1 + 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/TabBar.cpp b/src/TabBar.cpp index ddcb1010..b7500b2e 100644 --- a/src/TabBar.cpp +++ b/src/TabBar.cpp @@ -55,6 +55,7 @@ CTabBar::CTabBar(HINSTANCE hInst) , m_tabBarDefaultProc(nullptr) , m_tabBarSpinDefaultProc(nullptr) , m_spin(nullptr) + , m_bIsSpinVisible(false) , m_currentHoverTabItem(-1) , m_bIsCloseHover(false) , m_whichCloseClickDown(-1) @@ -483,7 +484,7 @@ LRESULT CTabBar::RunProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) DrawMainBorder(&dis); - if (m_spin) + if (m_bIsSpinVisible) { RECT rcSpin{}; GetWindowRect(m_spin, &rcSpin); @@ -677,7 +678,7 @@ LRESULT CTabBar::RunProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) auto index = GetTabIndexAt(xPos, yPos); RECT rcItem{}; TabCtrl_GetItemRect(*this, index, &rcItem); - if (m_spin) + if (m_bIsSpinVisible) { RECT rcSpin{}; GetWindowRect(m_spin, &rcSpin); @@ -754,7 +755,7 @@ LRESULT CTabBar::RunProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) RECT rPage{}; GetClientRect(*this, &rPage); TabCtrl_AdjustRect(*this, FALSE, &rPage); - if (m_spin) + if (m_bIsSpinVisible) { RECT rcSpin{}; GetWindowRect(m_spin, &rcSpin); @@ -1272,6 +1273,13 @@ LRESULT CTabBar::TabBarSpin_Proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM { case WM_PAINT: { + // as WM_SHOWWINDOW is only ever sent with wParam == FALSE, use WM_PAINT instead of WM_SHOWWINDOW with wParam == TRUE + // alternatives might be WM_NCPAINT or 1125, which also both seem to be only sent when updown control is unhidden + if (!pTab->m_bIsSpinVisible) + { + pTab->m_bIsSpinVisible = true; + } + PAINTSTRUCT ps; BeginPaint(hwnd, &ps); HDC hdc = ps.hdc; @@ -1472,8 +1480,23 @@ LRESULT CTabBar::TabBarSpin_Proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM InvalidateRect(hwnd, nullptr, false); } break; + case WM_SHOWWINDOW: + { + if (wParam == FALSE) //< checked and is only ever sent with wParam == FALSE + { + pTab->m_bIsSpinVisible = false; + } + /* + else + { + pTab->m_bIsSpinVisible = true; + } + */ + break; + } case WM_DESTROY: { + pTab->m_bIsSpinVisible = false; pTab->m_spin = nullptr; break; } @@ -1533,6 +1556,7 @@ void CTabBar::SubclassSpinBox() pThis->m_tabBarSpinDefaultProc = reinterpret_cast(::SetWindowLongPtr(hChild, GWLP_WNDPROC, reinterpret_cast(TabBarSpin_Proc))); pThis->m_spin = hChild; + pThis->m_bIsSpinVisible = true; return FALSE; } return TRUE; diff --git a/src/TabBar.h b/src/TabBar.h index 322e0971..45a0754a 100644 --- a/src/TabBar.h +++ b/src/TabBar.h @@ -145,6 +145,7 @@ class CTabBar : public CWindow WNDPROC m_tabBarDefaultProc; WNDPROC m_tabBarSpinDefaultProc; HWND m_spin; + bool m_bIsSpinVisible; RECT m_currentHoverTabRect; int m_currentHoverTabItem;