LCL/ShellListView: Reserve space for vertical scroll bar in Resize. Issue #39333, based on patches by Don Siders.

This commit is contained in:
wp_xyz 2021-08-18 19:16:38 +02:00
parent 10c474f730
commit 89299a2f6a

View File

@ -1581,6 +1581,8 @@ begin
end; end;
procedure TCustomShellListView.Resize; procedure TCustomShellListView.Resize;
var
iWidth: Integer;
begin begin
inherited Resize; inherited Resize;
{$ifdef DEBUG_SHELLCTRLS} {$ifdef DEBUG_SHELLCTRLS}
@ -1588,27 +1590,29 @@ begin
{$endif} {$endif}
// The correct check is with count, // The correct check is with count,
// if Column[0] <> nil then // if Column[0] <> nil then will raise an exception
// will raise an exception
if Self.Columns.Count < 3 then Exit; if Self.Columns.Count < 3 then Exit;
if (Column[0].Width <> 0) and (not AutoSizeColumns) then if (Column[0].Width <> 0) and (not AutoSizeColumns) then
Exit; Exit;
// If the space available is small, iWidth := ClientWidth;
// alloc a larger percentage to the secondary BeginUpdate;
// fields try
if Width < 400 then // If the space available is small, alloc a larger percentage to the secondary
begin // fields
Column[0].Width := (50 * Width) div 100; if Width < 400 then
Column[1].Width := (25 * Width) div 100; begin
Column[2].Width := (25 * Width) div 100; Column[0].Width := (50 * iWidth) div 100;
end Column[1].Width := (25 * iWidth) div 100;
else end
begin else
Column[0].Width := (70 * Width) div 100; begin
Column[1].Width := (15 * Width) div 100; Column[0].Width := (70 * iWidth) div 100;
Column[2].Width := (15 * Width) div 100; Column[1].Width := (15 * iWidth) div 100;
end;
Column[2].Width := iWidth - Column[0].Width - Column[1].Width;
finally
EndUpdate;
end; end;
{$ifdef DEBUG_SHELLCTRLS} {$ifdef DEBUG_SHELLCTRLS}