Kurt G 0 Posted September 24, 2022 I an totally new to RAD, and have installed RAD 11.2. I want to convert a project from Delphi5 to RAD 11.2 in Multi-Device App. as it can rotate an Image. I therefor started a new app. but I can not find anything like ListBox or FileListBox. Is there no procedure or function in RAD 11.2 to do the job? Is there another way i FMX to do it? Share this post Link to post
Kurt G 0 Posted September 24, 2022 Pardon, it is l"DirectoryListBox or FileListBox." Share this post Link to post
Pat Foley 51 Posted September 24, 2022 3 hours ago, Kurt G said: convert a project from Delphi5 to RAD 11.2 in Multi-Device App. Best to leave that D5 code behind. FMX code can be earned by running the example samples for FMX. The FMX code has an OpenDialog component that might give you start. Share this post Link to post
Kurt G 0 Posted September 25, 2022 I have given up the D5 code. I started from beginning by selecting Multi-Device Application. But I still nead the function to list directory and files, and I have not found any examples for that until now. Share this post Link to post
Rollo62 536 Posted September 25, 2022 Its not a listbox, but maybe the System.IOUtils unit help you with that. Share this post Link to post
Pat Foley 51 Posted September 25, 2022 FMX does have TListView. procedure TForm9.Button1Click(Sender: TObject); var Lvi : TListViewItem; I : Integer; DirArray : TStringDynArray; begin Lvi := ListView1.Items.Add; Lvi.Text := 'Hello'; Lvi := ListView1.Items.Add; Lvi.Text := 'FMX'; Lvi := ListView1.Items.Add; Lvi.Text := Tdirectory.GetCurrentDirectory; DirArray := TDirectory.GetFiles(Lvi.Text); var Filename: string; for I := 0 to High(DirArray) do begin Filename := DirArray[I]; Lvi := ListView1.Items.Add; Lvi.Text := fileName; end; end; Share this post Link to post
Kurt G 0 Posted September 30, 2022 unit Unit1; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Controls.Presentation, FMX.StdCtrls, FMX.Layouts, System.IOUtils, FMX.ListBox; type TForm1 = class(TForm) Button1: TButton; ListBox1: TListBox; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.fmx} procedure TForm1.Button1Click(Sender: TObject); var Lvi : TListViewItem; I : Integer; DirArray : TStringDynArray; begin Lvi := ListView1.Items.Add; Lvi.Text := 'Hello'; Lvi := ListView1.Items.Add; Lvi.Text := 'FMX'; Lvi := ListView1.Items.Add; Lvi.Text := Tdirectory.GetCurrentDirectory; DirArray := TDirectory.GetFiles(Lvi.Text); var Filename: string; for I := 0 to High(DirArray) do begin Filename := DirArray; Lvi := ListView1.Items.Add; Lvi.Text := fileName; end; end; end. ----------------------------------------------------- A lot has happened since D5! 🙂 I started a new project and placed a Tbutton and a TListBox on the form. But the compiler give error: Undeclared identifier: TListviewItem in the line: Lvi : TListViewItem; See the code in Unit.pas. Unit1.pas Share this post Link to post
Pat Foley 51 Posted September 30, 2022 On 9/25/2022 at 1:28 PM, Pat Foley said: FMX does have TListView. So discard old ListBox and use TListView component. Also add a memo1 and this procedure TForm9.ListView1Change(Sender: TObject); var fn: string; begin fn := Listview1.items[ListView1.ItemIndex].Text; if Pos('.txt',Fn) > 0 then memo1.Lines.LoadFromFile(fn); end; Share this post Link to post
Serge_G 87 Posted October 1, 2022 (edited) 16 hours ago, Kurt G said: But the compiler give error: Undeclared identifier: TListviewItem in the line: Lvi : TListViewItem; You declare a TListbox not a TListView so it's normal, units for Tlistview ( FMX.TlistView,FMX.TlistView.xxxx) are not declared works with a TlistView A list box (simple one without style) should be filled with Listbox1.Items.Add('Hello') other way is to declare a TListboxItem var aItem : TlistboxItem; begin aItem:=TlistboxItem.Create(Self); aItem.Parent:=ListBox1; aItem.Text:='Hello'; end; P.S. If you want to involve style, here is a tutorial I wrote (long time ago, XE4, when TListview does not exists) Intro to styles Firemonkey XE4 (sorry in French) Edited October 1, 2022 by Serge_G Share this post Link to post
Kurt G 0 Posted October 1, 2022 Thanks for your help, it's starting to come through. I am having problems with the components disappearing from the Frame. I must have found a tutorial about the IDE, but it shouldn't be YOU TUBE, I prefer to read. Share this post Link to post
Pat Foley 51 Posted October 1, 2022 Serge_G listbox coding is very nice example. Serge's "Introduction to FireMonkey XE4 Styles" is good start about differences between FMX and VCL and in text! His A.F.R.O may help you with the disappearing. Here's a one liner that brings up the opendialog and returns the directory or folder selected. if not SelectDirectory('Dirs, Folders','', FilePath) then exit; DirArray := TDirectory.GetFiles(FilePath,'*.*',TSearchOption.soTopDirectoryOnly); ... Share this post Link to post
Serge_G 87 Posted October 1, 2022 35 minutes ago, Pat Foley said: Serge_G listbox coding is very nice example. Serge's "Introduction to FireMonkey XE4 Styles" is good start about differences between FMX and VCL and in text! His A.F.R.O may help you with the disappearing. Thanks, but this AFRO thing is now obsolete because IDE force it when you close designer (ouf) Share this post Link to post
Pat Foley 51 Posted October 1, 2022 20 minutes ago, Serge_G said: because IDE force it when you close designer What happens in Multi-Device Preview when design window closed? Another goodie is the form screen position shows the wallpaper in color, albeit only follows left and Top and not property position setting. Share this post Link to post
Kurt G 0 Posted November 17, 2022 I don't know what "AFRO" and "(ouf)" in "Thanks, but this AFRO thing is now obsolete because IDE force it when you close designer (ouf)" mean. Can anyone help? Share this post Link to post
XylemFlow 8 Posted November 18, 2022 (edited) TListBox is there in FMX. I'm not sure why you think it's not. Regarding rotating images. You may know this already but the best way to do it is by setting the Matrix property of the TCanvas you're drawing to. Use TMatrix.CreateRotation to create the matrix from a rotation angle. The advantage of this method is that the GPU takes care of all the transformations. It's also easy to combine with other transformations such as scaling or translation. TBitmap.Rotate is essentially doing that for you, but gives you less control. Edited November 18, 2022 by XylemFlow Share this post Link to post