findinfiles uses tselectdirectorydialog; remove global SelectDirectory function (from vincent)

git-svn-id: trunk@5094 -
This commit is contained in:
micha 2004-01-24 11:42:53 +00:00
parent 5c441f1564
commit 39eee1a5a3
4 changed files with 20 additions and 69 deletions

View File

@ -24,7 +24,7 @@ interface
uses
Classes, SysUtils, LCLIntf, Controls, StdCtrls, Forms, Buttons, ExtCtrls,
LResources, FileCtrl, LazarusIDEStrConsts, DirSel, Dialogs, SynEditTypes;
LResources, FileCtrl, LazarusIDEStrConsts, Dialogs, SynEditTypes;
type
TLazFindInFileSearchOption = (fifMatchCase, fifWholeWord, fifRegExpr,
@ -46,6 +46,7 @@ type
DirectoryLabel: TLabel;
DirectoryComboBox: TComboBox;
DirectoryBrowse: TBitBtn;
SelectDirectoryDialog: TSelectDirectoryDialog;
FileMaskLabel: TLabel;
FileMaskComboBox: TComboBox;
IncludeSubDirsCheckBox: TCheckBox;
@ -200,6 +201,10 @@ begin
OnClick:=@DirectoryBrowseClick;
end;
SelectDirectoryDialog := TSelectDirectoryDialog.Create(Self);
with SelectDirectoryDialog do
Options:= Options + [ofPathMustExist];
FileMaskLabel:=TLabel.Create(Self);
with FileMaskLabel do begin
Name:='FileMaskLabel';
@ -356,16 +361,10 @@ begin
end;//WhereRaidoGroupClick
procedure TLazFindInFilesDialog.DirectoryBrowseClick(Sender: TObject);
var
TheDirectory: string; //Starting Directory and
//Directory Returned from Function
TheRootDir: string; //The root directory on the current dirve
begin
TheDirectory:= GetCurrentDir;
TheRootDir:= ExtractFileDrive(TheDirectory);
TheRootDir:= FileCtrl.AppendPathDelim(TheRootDir);
if SelectDirectory('Select A Directory', TheRootDir, TheDirectory, false) then
DirectoryComboBox.Text:= TheDirectory;
SelectDirectoryDialog.InitialDir:= GetCurrentDir;
if SelectDirectoryDialog.Execute then
DirectoryComboBox.Text:= SelectDirectoryDialog.FileName;
end;//DirectoryBrowseClick
procedure TLazFindInFilesDialog.SetOptions(

View File

@ -313,18 +313,7 @@ type
Function InputBox(const ACaption, APrompt, ADefault : String) : String;
Function PasswordBox(const ACaption, APrompt : String) : String;
{ Directory Selection }
type
TSelectDirectoryProc = function(const Caption: String; const Root: string;
var Directory: string; ShowHidden: Boolean): Boolean;
function SelectDirectory(const Caption: String; const Root: string;
var Directory: string; ShowHidden: Boolean): Boolean;
var
SelectDirectoryProc: TSelectDirectoryProc;
procedure Register;
implementation
@ -392,14 +381,6 @@ begin
Result := MessageDlg(Caption,Text,DlgType,Buttons,0);
end;
function SelectDirectory(const Caption: String; const Root: string;
var Directory: string; ShowHidden: Boolean): Boolean;
begin
Result:=false;
if Assigned(SelectDirectoryProc) then
Result:=SelectDirectoryProc(Caption,Root,Directory,ShowHidden);
end;
{$I colordialog.inc}
{$I commondialog.inc}
@ -414,7 +395,6 @@ initialization
Forms.MessageBoxFunction:=@ShowMessageBox;
InterfaceBase.InputDialogFunction:=@ShowInputDialog;
InterfaceBase.PromptDialogFunction:=@ShowPromptDialog;
SelectDirectoryProc:=nil;
finalization
@ -423,6 +403,9 @@ end.
{ =============================================================================
$Log$
Revision 1.41 2004/01/24 11:42:53 micha
findinfiles uses tselectdirectorydialog; remove global SelectDirectory function (from vincent)
Revision 1.40 2004/01/13 16:39:01 mattias
changed consistency stops during var renaming to errors

View File

@ -264,30 +264,7 @@ begin
Result:= GetAbsolutePath(TV.Selected);
end;//SelectedDir
function InternalSelectDirectory(const Caption: String;
const Root: string; var Directory: string; ShowHidden: Boolean): Boolean;
var
Dlg: TDirSelDlg;
begin
Dlg := TDirSelDlg.Create(Application);
if Dlg <> nil then
begin
try
Dlg.ShowHidden := ShowHidden;
Dlg.RootDirectory := Root;
Dlg.Directory := Directory;
Dlg.Caption := Caption;
Result := Dlg.ShowModal = mrOK;
if Result then Directory := Dlg.SelectedDir;
finally
Dlg.Free;
end;
end;//if
end;
initialization
{$I dirsel.lrs}
SelectDirectoryProc:=@InternalSelectDirectory;
end.

View File

@ -787,22 +787,14 @@ Var
B : Boolean;
begin
If Assigned(SelectDirectoryProc) then
begin
D:=Text;
B:=SelectDirectory(DialogTitle,RootDir,D,ShowHidden);
end
else
begin
Dlg:=CreateDialog;
Try
B:=Dlg.Execute;
If B then
D:=GetDialogResult(Dlg);
Finally
Dlg.Free;
end;
end;
Dlg:=CreateDialog;
Try
B:=Dlg.Execute;
If B then
D:=GetDialogResult(Dlg);
Finally
Dlg.Free;
end;
If B then
begin
If Assigned(FOnAcceptDir) then