Sinon il y a la possibilité de faire un composant hérité de TOpenDialog :
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 := 'Dummy.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,'Répertoire :'); SetDlgItemText(GetParent(Handle),1,'OK'); end; end;
function TDirDialog.Execute: Boolean; begin FIsJustExecute := True; if Title='' then Title := 'Sélectionnez un répertoire'; Result := inherited Execute; end;
function TDirDialog.GetDirectory: string; begin if FileName<>'' then if ExtractFileName(FileName)='Dummy.dat' then Result:=ExtractFileDir(FileName) else Result:=FileName else Result:=''; end;
procedure TDirDialog.SetDirectory(Directory: string); begin FileName := IncludeTrailingBackslash(Directory) + 'Dummy.dat'; end;
procedure Register; begin RegisterComponents('Dialogues', [TDirDialog]); end;
end. //--------------------------------------------------------------------- // 1 -> Bouton Ouvrir // 2 -> Bouton Annuler // 1038 -> Bouton Aide // 1040 -> Case à cocher "Lecture Seule" // 1089 -> Label "Type de fichier" // 1090 -> Label "Nom du fichier" // 1091 -> Label "Rechercher dans" // 1120 -> ? // 1136 -> ComboBox "Type de fichier" // 1137 -> ComboBox "Rechercher dans" // 1152 -> Edit "Nom du fichier" //---------------------------------------------------------------------------
|