unit Unit2;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
  Buttons;

type

  { TForm2 }

  TForm2 = class(TForm)
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    BitBtn3: TBitBtn;
    Button1: TButton;
    ListBox1: TListBox;
    OpenDialog1: TOpenDialog;
    Panel1: TPanel;
    SelectDirectoryDialog1: TSelectDirectoryDialog;
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
  private

  public

  end;

var
  Form2: TForm2;

implementation
 uses Unit1;
{$R *.lfm}

{ TForm2 }

procedure TForm2.BitBtn1Click(Sender: TObject);
var fullFileName, FileName, dir : String;
begin
     dir := ExtractFileDir(Unit1.fullFileName);
    OpenDialog1.InitialDir:=dir;
    if OpenDialog1.Execute then
  begin
   fullFileName := OpenDialog1.FileName;
   FileName := ExtractFileName(fullFileName);
   ListBox1.Items.Add(FileName);
  end;
end;

procedure TForm2.BitBtn2Click(Sender: TObject);
var fullFileName, FileName, dir: String;
begin
    dir := ExtractFileDir(Unit1.fullFileName);
    SelectDirectoryDialog1.InitialDir:=dir;
    if SelectDirectoryDialog1.Execute then
  begin
   fullFileName := SelectDirectoryDialog1.FileName;
   FileName := ExtractFileName(fullFileName);
   ListBox1.Items.Add(FileName);
  end;

end;

procedure TForm2.BitBtn3Click(Sender: TObject);
begin
  close;
end;

end.

