View Single Post
  #399  
Old 07-10-2023, 05:52
hitman797's Avatar
hitman797 hitman797 is offline
Registered User
 
Join Date: Feb 2013
Location: Algeria
Posts: 168
Thanks: 486
Thanked 202 Times in 122 Posts
hitman797 is on a distinguished road
Code:
procedure TDialogForm.Button1Click(Sender: TObject);
begin
  if length(Label1.Text) = 3 then
  begin
    CreateDir(Label1.Text+Edit1.Text);
    Label1.Text:= Label1.Text+Edit1.Text;
  end else begin
    CreateDir(Label1.Text+'\'+Edit1.Text);
    Label1.Text:= Label1.Text+'\'+Edit1.Text;
  end;
  Timer1.Enabled:= True;
end;

procedure TDialogForm.FormCreate(Sender: TObject);
var
 hDriveArry: TStringDynArray;
 hDriveName: String;
begin
  ListBox1.Clear;
  ListBox1.BeginUpdate;
  hDriveArry:= TDirectory.GetLogicalDrives;
  for hDriveName in hDriveArry do
  begin
   ListBox1.Items.Add(hDriveName);
  end;
  ListBox1.EndUpdate;
  Timer1.Enabled:= True;
end;

procedure TDialogForm.ListBox1ItemClick(const Sender: TCustomListBox;
  const Item: TListBoxItem);
begin
  Label1.Text:= ListBox1.Items.Strings[ListBox1.ItemIndex];
  Timer1.Enabled:= True;
end;

procedure TDialogForm.ListBox2ItemClick(const Sender: TCustomListBox;
  const Item: TListBoxItem);
begin
  if length(Label1.Text) = 3 then
  begin
    Label1.Text:= Label1.text+ListBox2.Items.Strings[ListBox2.ItemIndex];
  end else begin
    Label1.Text:= Label1.text+'\'+ListBox2.Items.Strings[ListBox2.ItemIndex];
  end;
  Timer1.Enabled:= True;
end;

procedure TDialogForm.SpeedButton1Click(Sender: TObject);
begin
  Label1.Text:= 'C:\Windows';
  Timer1.Enabled:= True;
end;

procedure TDialogForm.SpeedButton2Click(Sender: TObject);
begin
  Label1.Text:= ExtractFileDir(Label1.Text);
  Timer1.Enabled:= True;
end;

procedure TDialogForm.Timer1Timer(Sender: TObject);
var
 hDirArry: TStringDynArray;
 hDirName: String;
begin
  ListBox2.Clear;
  ListBox2.BeginUpdate;
  hDirName:= Label1.Text;
  hDirArry:= TDirectory.GetDirectories(hDirName);
  for hDirName in hDirArry do
  begin
    ListBox2.Items.Add(ExtractFileName(hDirName));
  end;
  ListBox2.EndUpdate;
  Timer1.Enabled:= False;
end;
Attached Images
File Type: png Capture.PNG (20.5 KB, 132 views)
Attached Files
File Type: 7z Project9.7z (10.59 MB, 28 views)
Reply With Quote
The Following 2 Users Say Thank You to hitman797 For This Useful Post:
ADMIRAL (14-11-2023), audiofeel (08-10-2023)