(************************************************************************
*    This File is Part of the AHM Triton Tools                          *
*    for Borland Delphi and C++ Builder.                                *
*************************************************************************
* Copyright © 1995-1999 Alexander H. Mehlhorn (AHM) and Tritontools.com *
* All Rights reserved.                                                  *
*                                                                       *
*    For more Information contact us at                                 *
*    E-Mail : support@tritontools.com                                   *
*    URL : http://www.tritontools.com                                   *
*                                                                       *
*    AHM is copyright by Alexander H. Mehlhorn                          *
*    All Parts of this Collection were developed,                       *
*    designed and implemented by AHM                                    *
*                                                                       *
*    Under no Circumstances may you distribute this file                *
*    in this or any other format. This File is supplied                 *
*    as Evaluation of Source only. No Delphi Components may be developed*
*    using extracts or subsets of this code without expressed permission*
*    by AHM.                                                            *
*                                                                       *
*************************************************************************)
unit AHMTFileLookup;

interface
{$I AHM.INC}
{$R *.res}
uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Mask, AHMTLookupEdit,AHMStdClass;

type
  TAHMFileLookup = class(TAHMCustomLookupEdit)
  private
    FFilter,FDefaultExt,FTitle,FInitialDir : String;
    FOptions : TOpenOptions;
    Procedure GetFilenameDialog(Sender : TObject);
    Function GetFilename : String;
    Procedure SetFilename(Value : String);
  protected
  public
    constructor create(AOwner : TComponent); override;
    procedure CreateParams(var Params: TCreateParams); override;
  published
    {$IFDEF AHMONLY4}
    property Anchors;
    property BiDiMode;
    property Constraints;
    property DragCursor;
    property DragKind;
    property DragMode;
    property ParentBiDiMode;
    {$ENDIF}
    property Options : TOpenOptions read FOptions write FOptions;
    property Title : String read FTitle write FTitle;
    property InitialDir : String read FInitialDir write FInitialDir;
    property Filename : String read GetFilename write SetFilename;
    property Filter : String read FFilter write FFilter;
    property DefaultExt : String read FDefaultExt write FDefaultExt stored True;
    property EditButton1;
    property Alignment;
    property MaxLength;
    property AutoSize;
    property CharCase;
    Property Enabled;
    Property ReadOnly;
    property Font;
    property OnChange;
    property OnEnter;
    property OnExit;
    property OnKeyDown;
    property OnKeyPress;
    property OnKeyUp;
    property OnClick;
    property OnDblClick;
    property OnDragDrop;
    property OnDragOver;
    property OnEndDrag;
    property OnMouseDown;
    property OnMouseMove;
    property OnMouseUp;
    property OnStartDrag;
  end;


implementation

constructor TAHMFileLookup.create(AOwner : TComponent);
begin
  FFilter:='All Files|*.*';
  inherited Create(AOwner);
  EditButton1.Glyph.LoadFromResourceName(HInstance,'TAHMFileLookupA');
  EditButton1.NumGlyphs:=2;
  Text:='';
  EditButton2.Visible:=False;
  OnButton1Click:=GetFilenameDialog;
end;

procedure TAHMFileLookup.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(Params);
end;

Function TAHMFileLookup.GetFilename : String;
begin
  Result:=self.Text;
end;

Procedure TAHMFileLookup.SetFilename(Value : String);
begin
  self.Text:=Value;
end;

Procedure TAHMFileLookup.GetFilenameDialog(Sender : TObject);
Var FOpenDialog : TOpenDialog;
begin
  FOpenDialog:=TOpenDialog.Create(Application);
  with FOpenDialog do
  try
    FOpenDialog.DefaultExt:=FDefaultExt;
    FOpenDialog.InitialDir:=FInitialDir;
    FOpenDialog.Filter:=FFilter;
    FOpenDialog.Filename:=GetFilename;
    FOpenDialog.Options:=FOptions;
    FOpenDialog.Title:=FTitle;
    if Execute then SetFilename(FOpenDialog.Filename);
  finally
    free;
  end;
end;

end.
