home *** CD-ROM | disk | FTP | other *** search
- unit ushbr;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls, JPRShBr;
-
- type
- TForm1 = class(TForm)
- ShellBrowser1: TShellBrowser;
- Button1: TButton;
- edPrompt: TEdit;
- edInitialPath: TEdit;
- edRootPath: TEdit;
- Label3: TLabel;
- Label1: TLabel;
- edStatusText: TEdit;
- lResult: TLabel;
- GroupBox1: TGroupBox;
- cbBrowseForComputer: TCheckBox;
- cbBrowseForPrinter: TCheckBox;
- CheckBox3: TCheckBox;
- CheckBox4: TCheckBox;
- CheckBox5: TCheckBox;
- CheckBox6: TCheckBox;
- Memo1: TMemo;
- Label4: TLabel;
- edCaption: TEdit;
- Label5: TLabel;
- Label2: TLabel;
- Label6: TLabel;
- lPathName: TLabel;
- lDispName: TLabel;
- procedure Button1Click(Sender: TObject);
- procedure ShellBrowser1Initialize(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure ShellBrowser1SelChange(Sender: TObject; NewFolder: string;
- IsDisplayName: Boolean);
- public
- procedure Options2CB;
- procedure CB2Options;
- function GetFolderDetails(APath:String):String;
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- procedure TForm1.CB2Options;
- var
- i : integer;
- begin
- ShellBrowser1.Options := [];
- for i := 0 to GroupBox1.ControlCount-1 do
- with Groupbox1.Controls[i] as TCheckbox do
- if Checked then
- ShellBrowser1.Options := ShellBrowser1.Options+
- [TShellBrowserOption(i)];
-
- end;
-
- procedure TForm1.Options2CB;
- var
- i : TShellBrowserOption;
- begin
- With ShellBrowser1 do begin
- for i := Low(TShellBrowserOption) to High(TShellBrowserOption) do
- (GroupBox1.Controls[Ord(i)] as TCheckbox).Checked := i in Options;
- edInitialPath.Text := InitialPath;
- edRootPath.Text := RootPath;
- edStatusText.Text := StatusText;
- edPrompt.Text := Prompt;
- edCaption.Text := Caption;
- lPathName.Caption := PathName;
- lDispName.Caption := DisplayName;
- end;
-
-
- end;
-
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- Memo1.Lines.Clear;
- With ShellBrowser1 do begin
- InitialPath := edInitialPath.Text;
- RootPath := edRootPath.Text;
- StatusText := edStatusText.Text;
- Prompt := edPrompt.Text;
- Caption := edCaption.Text;
- end;
-
- CB2Options;
-
- lResult.Caption := 'Executing';
-
- if ShellBrowser1.Execute then
- lResult.Caption := 'OK was pressed'
- else
- lResult.Caption := 'Cancel was pressed';
-
- Options2CB;
- end;
-
- procedure TForm1.ShellBrowser1Initialize(Sender: TObject);
- begin //
- Memo1.Lines.Add('Initialize');
- end;
-
- function TForm1.GetFolderDetails(APath:String):String;
- var
- SR:TSearchRec;
- D :TDateTime;
- begin
- Result := APath;
- try
- FindFirst(APath,faAnyFile,SR);
- try
- D := FileDateToDateTime(SR.Time);
- Result := Result+' [Created: '+DateTimeToStr(D)+']';
- finally
- FindClose(SR);
- end;
- except
- on E:Exception do Result := 'Error: '+E.Message;
- end;
- end;
-
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- Options2CB;
- end;
-
- procedure TForm1.ShellBrowser1SelChange(Sender: TObject; NewFolder: string;
- IsDisplayName: Boolean);
- begin
- Memo1.Lines.Add(' SelChange: '+NewFolder);
- if NewFolder <> '' then
- ShellBrowser1.StatusText := GetFolderDetails(NewFolder)
- else
- ShellBrowser1.StatusText := '';
- end;
-
- end.
-
-
-