unit ufigura;

interface

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

type
  TOKFiguraDlg = class(TForm)
    OKBtn: TButton;
    CancelBtn: TButton;
    Bevel1: TBevel;
    Label1: TLabel;
    e_nomeFig: TEdit;
    Label2: TLabel;
    e_comentFig: TEdit;
    Button1: TButton;
    OpenDialog1: TOpenDialog;
    procedure Button1Click(Sender: TObject);
    procedure OKBtnClick(Sender: TObject);
    procedure CancelBtnClick(Sender: TObject);
    procedure FormActivate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    ok: boolean;
  end;

var
  OKFiguraDlg: TOKFiguraDlg;

implementation

{$R *.dfm}

procedure TOKFiguraDlg.Button1Click(Sender: TObject);
var nomeArq, saveDir: string;
    n: integer;
begin
    getDir (0, savedir);
    if openDialog1.execute then
        nomeArq := OpenDialog1.FileName;
    chdir (savedir);

    if pos (ansiUpperCase(savedir), ansiUpperCase (nomeArq)) = 1 then
        begin
            delete (nomeArq, 1, length(savedir));
            if copy (nomeArq, 1, 1) = '\' then
                delete (nomeArq, 1, 1);
            repeat
                n := pos ('\', nomeArq);
                if n <> 0 then
                    nomeArq[n] := '/';
            until n = 0;
       end;

    e_nomeFig.Text := nomeArq;
end;

procedure TOKFiguraDlg.OKBtnClick(Sender: TObject);
begin
   if e_nomeFig.Text <> '' then
      ok := true
   else
      ok := false;
end;

procedure TOKFiguraDlg.CancelBtnClick(Sender: TObject);
begin
   ok := false;
end;

procedure TOKFiguraDlg.FormActivate(Sender: TObject);
begin
    e_nomeFig.Clear;
    e_comentFig.Clear;
end;

end.
