Delphi 2007中默认没有ShellTreeView控件,但是有ShellCtrls,dcu单元,所以我们可以使用此单元然后动态创建这个Delphi 7中有的控件:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,ShellCtrls,StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
s:TShellTreeView;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
s:=TShellTreeView.Create(self);
s.ParentWindow:=Form1.Handle;
s.Name:='ShellTree1';
s.Left:=0;
s.Top:=0;
s.Width:=201;
s.Height:=209;
s.Root:='rfDesktop'; //rfMyComputer
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if DirectoryExists(s.path)then
caption:=s.Path;
end;
end.
Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号
执行时间: 0.038973808288574 seconds