wiem że nie mogę o to prosić ale już mam taki burdel że nie wiem jak to poukładać z tym co było
znalazł byś czas by to wszystko ułożyć ? Proszę, pewnie przez to ze to mam na dwóch formach już mam mętlik Sama już widzę potrójnie ten kod
Zrobiłam to na jedną formę Wyrzuciłam wszystko od nowa na jedną formę: Zerknij tylko
burzy się funkcja - TForm1.ListBox1DrawItem- pewnie zapomniałam o czymś i buton 2 nie doaje plików do listboxa (buton 1 miałał tylko zapisać ścieżkę) Ja już mam mętlik i depresje jak baba chyba się poddaje
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs,Vcl.FileCtrl, Vcl.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
ListBox1: TListBox;
Button2: TButton;
Labelpath:TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure ListFiles(const APath: String; AFilesList: TStrings);
var
LFileRec: TSearchRec;
begin
if FindFirst(APath + '*.mp3', faAnyFile, LFileRec) = 0 then
try
repeat
AFilesList.Add(APath + LFileRec.Name); // doaje całą ścieżke
until FindNext(LFileRec) <> 0;
finally
FindClose(LFileRec);
end;
if FindFirst(APath + '*.*', fadirectory, LFileRec) = 0 then
try
repeat
if (LFileRec.Name <> '.') and (LFileRec.Name <> '..') then
ListFiles (APath + LFileRec.Name + '\', AFilesList);
until FindNext(LFileRec) <> 0;
finally
FindClose(LFileRec);
end;
end;
procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
var
Flags: Longint;
Data: String;
begin
self.ListBox1.canvas.FillRect(Rect);
Flags := DrawTextBiDiModeFlags(DT_SINGLELINE or DT_VCENTER or DT_NOPREFIX);
Data := inttostr(index + 1) + ' : ' + extractfilename(self.ListBox1.Items[index]);
DrawText(self.ListBox1.canvas.Handle, Data, Length(Data), Rect, Flags);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Directory: String;
begin
if SelectDirectory('Dodaj pliki', 'C:', Directory) then
self.Labelpath.caption := Directory;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if trim(self.Labelpath.caption) <> '' then
ListFiles(IncludeTrailingPathDelimiter(self.Labelpath.caption), ListBox1.Items);
end;
end.