1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
unit DirDialog;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
FileCtrl;
type
TDirDialog = class(TOpenDialog)
private
FIsJustExecute: boolean;
function GetDirectory: string;
procedure SetDirectory(Directory: string);
protected
procedure DoFolderChange; override;
public
constructor Create(AOwner: TComponent); override;
function Execute: Boolean; override;
published
property FileName;
property Directory: string read GetDirectory write SetDirectory;
end;
procedure Register;
implementation
constructor TDirDialog.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FIsJustExecute := False;
FileName := 'Cincap.dat';
Filter := '*.*|*.*';
end;
procedure TDirDialog.DoFolderChange;
begin
inherited DoFolderChange;
if FIsJustExecute then
begin
FIsJustExecute := False;
ShowWindow(GetDlgItem(GetParent(Handle),1136),SW_HIDE);
ShowWindow(GetDlgItem(GetParent(Handle),1152),SW_HIDE);
SetDlgItemText(GetParent(Handle),1089,'');
SetDlgItemText(GetParent(Handle),1090,'');
SetDlgItemText(GetParent(Handle),1091,'Dossier :');
SetDlgItemText(GetParent(Handle),1,'OK');
end;
end;
function TDirDialog.Execute: Boolean;
begin
FIsJustExecute := True;
if Title='' then Title := 'Choix du dossier';
Result := inherited Execute;
end;
function TDirDialog.GetDirectory: string;
begin
if FileName<>'' then
if ExtractFileName(FileName)='Cincap.dat' then
Result:=ExtractFileDir(FileName)
else
Result:=FileName
else
Result:='';
end;
procedure TDirDialog.SetDirectory(Directory: string);
begin
FileName := IncludeTrailingBackslash(Directory) + 'Cincap.dat';
end;
procedure Register;
begin
RegisterComponents('Dialogues', [TDirDialog]);
end;
end. |
Partager