home *** CD-ROM | disk | FTP | other *** search
/ CD Shareware Magazine 1996 December / CD_shareware_12-96.iso / WIN / Programa / JPRSHBR.ZIP / USHBR.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1996-08-11  |  3.3 KB  |  150 lines

  1. unit ushbr;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls, JPRShBr;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     ShellBrowser1: TShellBrowser;
  12.     Button1: TButton;
  13.     edPrompt: TEdit;
  14.     edInitialPath: TEdit;
  15.     edRootPath: TEdit;
  16.     Label3: TLabel;
  17.     Label1: TLabel;
  18.     edStatusText: TEdit;
  19.     lResult: TLabel;
  20.     GroupBox1: TGroupBox;
  21.     cbBrowseForComputer: TCheckBox;
  22.     cbBrowseForPrinter: TCheckBox;
  23.     CheckBox3: TCheckBox;
  24.     CheckBox4: TCheckBox;
  25.     CheckBox5: TCheckBox;
  26.     CheckBox6: TCheckBox;
  27.     Memo1: TMemo;
  28.     Label4: TLabel;
  29.     edCaption: TEdit;
  30.     Label5: TLabel;
  31.     Label2: TLabel;
  32.     Label6: TLabel;
  33.     lPathName: TLabel;
  34.     lDispName: TLabel;
  35.     procedure Button1Click(Sender: TObject);
  36.     procedure ShellBrowser1Initialize(Sender: TObject);
  37.     procedure FormCreate(Sender: TObject);
  38.     procedure ShellBrowser1SelChange(Sender: TObject; NewFolder: string;
  39.       IsDisplayName: Boolean);
  40.   public
  41.     procedure Options2CB;
  42.     procedure CB2Options;
  43.     function GetFolderDetails(APath:String):String;
  44.   end;
  45.  
  46. var
  47.   Form1: TForm1;
  48.  
  49. implementation
  50.  
  51. {$R *.DFM}
  52.  
  53. procedure TForm1.CB2Options;
  54. var
  55.   i : integer;
  56. begin
  57.   ShellBrowser1.Options := [];
  58.   for i := 0 to GroupBox1.ControlCount-1 do
  59.     with Groupbox1.Controls[i] as TCheckbox do
  60.       if Checked then
  61.          ShellBrowser1.Options := ShellBrowser1.Options+
  62.               [TShellBrowserOption(i)];
  63.  
  64. end;
  65.  
  66. procedure TForm1.Options2CB;
  67. var
  68.   i : TShellBrowserOption;
  69. begin
  70.  With ShellBrowser1 do begin
  71.   for i := Low(TShellBrowserOption) to High(TShellBrowserOption) do
  72.     (GroupBox1.Controls[Ord(i)] as TCheckbox).Checked := i in Options;
  73.   edInitialPath.Text := InitialPath;
  74.   edRootPath.Text := RootPath;
  75.   edStatusText.Text := StatusText;
  76.   edPrompt.Text := Prompt;
  77.   edCaption.Text := Caption;
  78.   lPathName.Caption := PathName;
  79.   lDispName.Caption := DisplayName;
  80.   end;
  81.  
  82.  
  83. end;
  84.  
  85. procedure TForm1.Button1Click(Sender: TObject);
  86. begin
  87.   Memo1.Lines.Clear;
  88.   With ShellBrowser1 do begin
  89.      InitialPath := edInitialPath.Text;
  90.      RootPath := edRootPath.Text;
  91.      StatusText := edStatusText.Text;
  92.      Prompt := edPrompt.Text;
  93.      Caption := edCaption.Text;
  94.      end;
  95.  
  96.   CB2Options;
  97.  
  98.   lResult.Caption := 'Executing';
  99.  
  100.   if ShellBrowser1.Execute then
  101.      lResult.Caption := 'OK was pressed'
  102.   else
  103.      lResult.Caption := 'Cancel was pressed';
  104.  
  105.   Options2CB;
  106. end;
  107.  
  108. procedure TForm1.ShellBrowser1Initialize(Sender: TObject);
  109. begin //
  110.   Memo1.Lines.Add('Initialize');
  111. end;
  112.  
  113. function TForm1.GetFolderDetails(APath:String):String;
  114. var
  115.   SR:TSearchRec;
  116.   D :TDateTime;
  117. begin
  118.   Result := APath;
  119.   try
  120.   FindFirst(APath,faAnyFile,SR);
  121.    try
  122.     D := FileDateToDateTime(SR.Time);
  123.     Result := Result+' [Created: '+DateTimeToStr(D)+']';
  124.    finally
  125.     FindClose(SR);
  126.    end;
  127.   except
  128.     on E:Exception do Result := 'Error: '+E.Message;
  129.     end;
  130. end;
  131.  
  132. procedure TForm1.FormCreate(Sender: TObject);
  133. begin
  134.   Options2CB;
  135. end;
  136.  
  137. procedure TForm1.ShellBrowser1SelChange(Sender: TObject; NewFolder: string;
  138.   IsDisplayName: Boolean);
  139. begin
  140.   Memo1.Lines.Add('  SelChange: '+NewFolder);
  141.   if NewFolder <> '' then
  142.      ShellBrowser1.StatusText := GetFolderDetails(NewFolder)
  143.   else
  144.      ShellBrowser1.StatusText := '';
  145. end;
  146.  
  147. end.
  148.  
  149.  
  150.