I think the TShellListview was primarily designed to work in vsReport style. But here is a solution to get it working as you need:
The TShellListView inherits from TCustomListView a public property Column[index]: TListColumn. I thought that this property is for vsReport style only, but as i noticed the width of the first column is used also in vsList style. Since the ShellListview is designed with 3 columns by default I tried to set Column[0].Width to some reasonable value like 200. However, this did not work, the width was always autosizing to some value depending on the width of the control. The reason is in TCustomShellListView.Resize (I am removing the DEBUG instructrions and comments for simpler reading):
procedure TCustomShellListView.Resize;
begin
inherited Resize;
if Self.Columns.Count < 3 then Exit;
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;
end;
end;
As you can see the width of the three default columns is autocalculated as fractions of the control width. But, at the top, you can see that this does not happen when the number of columns is less than 3.
So, a simple, very hacky solution to your problem would be to delete one of the columns (but keep the first one) and set the width of the first column as you need. The following code gives the columns in vsList style a constant width of 200 pixels:
procedure TForm1.FormCreate(Sender: TObject);
begin
ShellListview1.Columns.Delete(2);
ShellListView1.Column[0].Width := 200;
end;
Of course, needless to say that you cannot return to vsReport style in this situation, you must recreate the deleted column before doing so. Therefore, I think a better solution would be to patch TCustomShellListView.Resize and exit when the viewstyle is not vrReport:
procedure TCustomShellListView.Resize;
begin
inherited Resize;
if (ViewStyle <> vrReport) or (Self.Columns.Count < 3) then Exit;
... // rest unchanged
end;
With this solution you still can change ViewStyle and adjust the column width:
procedure TForm1.StyleRadiobuttonChange(Sender: TObject);
begin
if Sender = rbListStyle then
begin
ShellListView1.ViewStyle := vsList;
ShellListView1.Column[0].Width := 200;
end else
ShellListView1.ViewStyle := vsReport;
end;
Let me think about it for a while, before I apply this solution to Laz trunk. Please report back when you see any issues with this solution.