@@ -53,6 +53,7 @@ TfrmExtFileDialog = class(TExtForm)
5353 procedure ShellListViewCompare (Sender: TObject; Item1, Item2: TListItem;
5454 Data: Integer; var Compare: Integer);
5555 procedure ShellListViewColumnClick (Sender: TObject; Column: TListColumn);
56+ procedure ShellListViewResize (Sender: TObject);
5657 procedure ShellTreeViewChange (Sender: TObject; Node: TTreeNode);
5758 procedure ShellTreeViewChanging (Sender: TObject; Node: TTreeNode;
5859 var AllowChange: Boolean);
@@ -148,10 +149,19 @@ procedure TfrmExtFileDialog.FormCreate(Sender: TObject);
148149 ShellListView.OnCompare := ShellListViewCompare;
149150 ShellListView.OnColumnClick := ShellListViewColumnClick;
150151 ShellListView.OnFileAdded := ShellListViewFileAdded;
152+ // AutoSizeColumns off: ShellCtrls' AdjustColWidths distributes the client width
153+ // over its 3 built-in columns only and would push additional columns out to the
154+ // right. Keep fixed widths for the secondary columns instead and let
155+ // ShellListViewResize fit the name column into the remaining space.
156+ ShellListView.AutoSizeColumns := False;
151157 with ShellListView.Columns.Add do begin
152158 Caption := _(' Modified' );
153159 Width := 140 ;
154160 end ;
161+ ShellListView.Columns[1 ].Width := 80 ; // Size
162+ ShellListView.Columns[2 ].Width := 80 ; // Type
163+ ShellListView.OnResize := ShellListViewResize;
164+ ShellListViewResize(ShellListView);
155165 FSortDirection := sdAscending;
156166 { $IFDEF WINDOWS}
157167 ShellListView.OnContextPopup := ShellListViewContextPopup;
@@ -472,6 +482,19 @@ procedure TfrmExtFileDialog.ShellListViewColumnClick(Sender: TObject;
472482 Column.SortIndicator := DirToIndicator[NewDirection];
473483end ;
474484
485+ procedure TfrmExtFileDialog.ShellListViewResize (Sender: TObject);
486+ var
487+ i, W: Integer;
488+ begin
489+ if ShellListView.Columns.Count > 1 then
490+ begin
491+ W := ShellListView.ClientWidth;
492+ for i := 1 to ShellListView.Columns.Count-1 do
493+ Dec(W, ShellListView.Columns[i].Width);
494+ ShellListView.Columns[0 ].Width := Max(50 , W);
495+ end ;
496+ end ;
497+
475498procedure TfrmExtFileDialog.ShellListViewContextPopup (Sender: TObject;
476499 MousePos: TPoint; var Handled: Boolean);
477500var
0 commit comments