没有,自己写。好简单的。你看看我写的这个例子.是类似Explorer的程序。可能对你有收获。
如果觉得满意,给分我吧。我没钱提一个比较难的问题了。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls, Menus;
type
TForm1 = class(TForm)
TreeView1: TTreeView;
ListView1: TListView;
Edit1: TEdit;
Button1: TButton;
OpenDialog1: TOpenDialog;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
procedure Button1Click(Sender: TObject);
procedure TreeView1Click(Sender: TObject);
procedure N1Click(Sender: TObject);
private
function GetTreePath(CurrentNode:TTreeNode):string;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var i,j,k:integer;
sr: TSearchRec;
Node1:TTreeNode;
s:string;
begin
OpenDialog1.InitialDir :=Edit1.text;
if OpenDialog1.Execute Then
begin
Edit1.Text :=ExtractFilePath(OpenDialog1.Filename);
TreeView1.Items.Clear;
Node1:=TreeView1.Items.Add(nil,Edit1.text);
i:=0;
while i<TreeView1.items.count do
begin
Node1:=TreeView1.Items.Item;
s:=GetTreePath(Node1);
j:=FindFirst(s+'*.*',faDirectory,sr);
k:=j;
while k=0 do
begin
if (sr.attr and faDirectory) = faDirectory then
if (sr.name<>'.') and (sr.name<>'..') then
TreeView1.items.AddChild(node1,sr.name+'/');
k:=FindNext(sr);
end;
if j=0 then FindClose(sr);
i:=i+1;
end;
TreeView1.FullExpand;
end;
end;
function TForm1.GetTreePath(CurrentNode:TTreeNode):string;
var
ParentNode:TTreeNode;
begin
result:=CurrentNode.text;
ParentNode:=CurrentNode.Parent;
while ParentNode<>nil do
begin
result:=ParentNode.text+result;
ParentNode:=ParentNode.Parent;
end;
end;
procedure TForm1.TreeView1Click(Sender: TObject);
var i,j:integer;
sr: TSearchRec;
Node:TTreeNode;
s:string;
NewColumn: TListItem;
begin
if TreeView1.selected=nil then exit;
s:=GetTreePath(TreeView1.selected)+'*.*';
ListView1.Items.Clear;
j:=FindFirst(s,0,sr);
i:=j;
while i=0 do
begin
NewColumn:=ListView1.items.Add;
NewColumn.Caption:=sr.name;
i:=FindNext(sr);
end;
if j=0 then FindClose(sr);
end;
procedure TForm1.N1Click(Sender: TObject);
var
Node:TTreeNode;
s:string;
begin
With TreeView1 do begin
Node:=Selected;
s:=IntToStr(random(MaxInt));
Node:=items.AddChild(node,s);
Selected:=Node;
end;
end;
end.