https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f23394986acd8f75dbbc5693f1dd0ac008e02233

commit f23394986acd8f75dbbc5693f1dd0ac008e02233
Author:     Hermès Bélusca-Maïto <hermes.belusca-ma...@reactos.org>
AuthorDate: Fri Mar 22 21:55:43 2024 +0100
Commit:     Hermès Bélusca-Maïto <hermes.belusca-ma...@reactos.org>
CommitDate: Wed Sep 18 12:31:48 2024 +0200

    [RAPPS] Recalculate the toolbar max buttons width when deleting the buttons 
(#6655)
    
    Done so that the toolbar can display correctly the buttons,
    and their labels if possible, when resizing the RAPPS window.
---
 base/applications/rapps/appview.cpp       | 20 +++++++++++++++-----
 base/applications/rapps/include/appview.h |  3 +++
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/base/applications/rapps/appview.cpp 
b/base/applications/rapps/appview.cpp
index 2dd08c2d7d3..e101416c94d 100644
--- a/base/applications/rapps/appview.cpp
+++ b/base/applications/rapps/appview.cpp
@@ -193,10 +193,8 @@ CMainToolbar::Create(HWND hwndParent)
 
     AddButtons(_countof(Buttons), Buttons);
 
-    /* Remember ideal width to use as a max width of buttons */
-    SIZE size;
-    GetIdealSize(FALSE, &size);
-    m_dButtonsWidthMax = size.cx;
+    /* Remember the ideal width to use as a max width of buttons */
+    UpdateMaxButtonsWidth();
 
     return m_hWnd;
 }
@@ -211,6 +209,14 @@ CMainToolbar::ShowButtonCaption(bool bShow)
         SendMessageW(TB_SETEXTENDEDSTYLE, 0, dCurrentExStyle | 
TBSTYLE_EX_MIXEDBUTTONS);
 }
 
+void
+CMainToolbar::UpdateMaxButtonsWidth()
+{
+    SIZE size;
+    GetIdealSize(FALSE, &size);
+    m_dButtonsWidthMax = size.cx;
+}
+
 DWORD
 CMainToolbar::GetMaxButtonsWidth() const
 {
@@ -1553,8 +1559,12 @@ CApplicationView::ProcessWindowMessage(
 
                 index = m_Toolbar->GetButtonInfo(ID_RESETDB, &info);
                 if (index >= 0) m_Toolbar->DeleteButton(index);
+
+                /* Update the ideal width to use as a max width of buttons */
+                m_Toolbar->UpdateMaxButtonsWidth();
             }
 
+            /* Resize the toolbar */
             m_Toolbar->AutoSize();
 
             RECT rTop;
@@ -1793,7 +1803,7 @@ CApplicationView::OnSize(HWND hwnd, WPARAM wParam, LPARAM 
lParam)
     if (wParam == SIZE_MINIMIZED)
         return;
 
-    /* Size tool bar */
+    /* Resize the toolbar */
     m_Toolbar->AutoSize();
 
     /* Automatically hide captions */
diff --git a/base/applications/rapps/include/appview.h 
b/base/applications/rapps/include/appview.h
index 0c9aa29a733..c53a6e81954 100644
--- a/base/applications/rapps/include/appview.h
+++ b/base/applications/rapps/include/appview.h
@@ -297,6 +297,9 @@ class CMainToolbar : public CUiWindow<CToolbar<>>
     void
     ShowButtonCaption(bool bShow);
 
+    void
+    UpdateMaxButtonsWidth();
+
     DWORD
     GetMaxButtonsWidth() const;
 };

Reply via email to