From 89299a2f6a8b2cbe52ea2d6d5faaa676cc67f9cd Mon Sep 17 00:00:00 2001 From: wp_xyz Date: Wed, 18 Aug 2021 19:16:38 +0200 Subject: [PATCH] LCL/ShellListView: Reserve space for vertical scroll bar in Resize. Issue #39333, based on patches by Don Siders. --- lcl/shellctrls.pas | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/lcl/shellctrls.pas b/lcl/shellctrls.pas index 77d5ad8226..d9d6ffce12 100644 --- a/lcl/shellctrls.pas +++ b/lcl/shellctrls.pas @@ -1581,6 +1581,8 @@ begin end; procedure TCustomShellListView.Resize; +var + iWidth: Integer; begin inherited Resize; {$ifdef DEBUG_SHELLCTRLS} @@ -1588,27 +1590,29 @@ begin {$endif} // The correct check is with count, - // if Column[0] <> nil then - // will raise an exception + // if Column[0] <> nil then will raise an exception if Self.Columns.Count < 3 then Exit; - if (Column[0].Width <> 0) and (not AutoSizeColumns) then Exit; - // If the space available is small, - // alloc a larger percentage to the secondary - // fields - if Width < 400 then - begin - Column[0].Width := (50 * Width) div 100; - Column[1].Width := (25 * Width) div 100; - Column[2].Width := (25 * Width) div 100; - end - else - begin - Column[0].Width := (70 * Width) div 100; - Column[1].Width := (15 * Width) div 100; - Column[2].Width := (15 * Width) div 100; + iWidth := ClientWidth; + BeginUpdate; + try + // If the space available is small, alloc a larger percentage to the secondary + // fields + if Width < 400 then + begin + Column[0].Width := (50 * iWidth) div 100; + Column[1].Width := (25 * iWidth) div 100; + end + else + begin + Column[0].Width := (70 * iWidth) div 100; + Column[1].Width := (15 * iWidth) div 100; + end; + Column[2].Width := iWidth - Column[0].Width - Column[1].Width; + finally + EndUpdate; end; {$ifdef DEBUG_SHELLCTRLS}