Recent

Author Topic: [CLOSED] Filelist scrollbox  (Read 8125 times)

pcurtis

  • Hero Member
  • *****
  • Posts: 951
[CLOSED] Filelist scrollbox
« on: December 08, 2021, 09:45:45 am »
Any ideas where or what I can use to show a horizontal list of files, preferably with icons?
« Last Edit: December 09, 2021, 11:52:55 am by pcurtis »
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

wp

  • Hero Member
  • *****
  • Posts: 11854
Re: Filelist scrollbox
« Reply #1 on: December 08, 2021, 11:14:35 am »
Use a TShellListView. In property "Root" specify the directory to be displayed. Select "vsSmallIcon" as "Viewstyle" in order to arrange the file names in rows. In Laz/main or v2.2RC2, the file names will be decorated with the associated icons automatically; in other versions and OSs you must provide an image list with the icons.

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: Filelist scrollbox
« Reply #2 on: December 08, 2021, 12:19:28 pm »
The control shows rows. I want one row that I can scroll left / right.
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

wp

  • Hero Member
  • *****
  • Posts: 11854
Re: Filelist scrollbox
« Reply #3 on: December 08, 2021, 12:49:07 pm »
To my knowledge there is no horizontal listbox/listview --> do it yourself...

You could use a TScrollbox and its ChildSizing property to autoalign run-time created labels for each file:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3.   L: TStringList;
  4.   i: Integer;
  5.   h: Integer;
  6. begin
  7.   L := TStringList.Create;
  8.   FindAllFiles(L, 'c:\', '*.*', false);
  9.   for i := 0 to L.Count-1 do
  10.   begin
  11.     with TLabel.Create(self) do
  12.     begin
  13.       Parent := Scrollbox1;
  14.       Caption := L[i];
  15.       h := Height;
  16.     end;
  17.   end;
  18.   L.Free;
  19.   Scrollbox1.ChildSizing.Layout := cclTopToBottomThenLeftToRight;
  20.   Scrollbox1.ChildSizing.ControlsPerLine := 1;  // Since we fill columns first, the "line" here runs vertically --> 1 control per column
  21.   Scrollbox1.ChildSizing.HorizontalSpacing := 12;  // horizontal distance between the labels
  22.   Scrollbox1.HorzScrollbar.Tracking := true;
  23.   Scrollbox1.ClientHeight := h;
  24. end;
« Last Edit: December 08, 2021, 10:09:54 pm by wp »

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: Filelist scrollbox
« Reply #4 on: December 08, 2021, 03:05:15 pm »
Thanks. It's a start.
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: Filelist scrollbox
« Reply #5 on: December 08, 2021, 06:53:03 pm »
OK, i've been playing
1. Scroll left  / right by keypress
2. Why does the button resize
3. When I do scroll how do I get the selected item
« Last Edit: December 08, 2021, 07:56:22 pm by pcurtis »
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

wp

  • Hero Member
  • *****
  • Posts: 11854
Re: Filelist scrollbox
« Reply #6 on: December 08, 2021, 07:48:48 pm »
1. Scroll left  / right by keypress
I think you have to do this yourself. You can access all buttons as the Controls[index] property of the scrollbox. Introduce an integer property for "ItemIndex". Write an OnKeyDown handler for each button which reacts on the horizontal arrow keys and moves the focus to the previous/next control and decrements/increments the ItemIndex.

2. Why does the button resize
This is a consequence of using the ChildSizing which overrides many other size- and position-related settings. But you can place the buttons into the scrollbox manually (leave ChildSizing at its default settings) and put the next button after the end of the previous button.

3. When I do scroll how do I get the selected item
I cannot say that I fully understand what you want to achieve. You only have a row of buttons, there is no "selected" button. Should the "selected" button remain pressed after clicking? In this case you could use TToggleBox rather than TButton. Or TSpeedButton, and make all buttons share the same non-zero GroupIndex which has the consequence that only the last clicked button is down (like radio buttons).
« Last Edit: December 08, 2021, 08:02:45 pm by wp »

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: Filelist scrollbox
« Reply #7 on: December 08, 2021, 07:54:06 pm »
How about scrolling?
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

wp

  • Hero Member
  • *****
  • Posts: 11854
Re: Filelist scrollbox
« Reply #8 on: December 08, 2021, 07:58:27 pm »
That's what it makes it hard for me to understand what you want. When you scroll the pressed button gets out of view, there's nothing to change that.

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: Filelist scrollbox
« Reply #9 on: December 08, 2021, 08:19:18 pm »
In end it wont be a button.

I just want to scroll L/R with a keypress
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

 

TinyPortal © 2005-2018