..........说实话,我实在想不明白你的要求里有什么有难度的地方.......
是不是下面这样的?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,jpeg, ExtCtrls, ComCtrls;
type
TForm1 = class(TForm)
TreeView1: TTreeView;
Image1: TImage;
procedure FormCreate(Sender: TObject);
procedure TreeView1Change(Sender: TObject; Node: TTreeNode);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
i:integer;
SRec:TSearchRec;
path,tmps:string;
pstr
char;
begin
TreeView1.Items.BeginUpdate;
try
path:='d:/MyPictures/动漫图片/';
if FindFirst(path+'*.jpg',faAnyFile,SRec)=0 then repeat
If (srec.Attr and FILE_ATTRIBUTE_DIRECTORY)<>0 Then //文件
continue;
tmps:=path+srec.Name+#0;
getmem(pstr,length(tmps));
strpcopy(pstr,tmps);
TreeView1.Items.AddChildObject(nil,changefileext(srec.Name,''),pstr);
until FindNext( SRec )<>0;
FindClose(SRec);
finally
TreeView1.Items.EndUpdate;
end;
end;
procedure TForm1.TreeView1Change(Sender: TObject; Node: TTreeNode);
var
tmps:string;
begin
tmps:=pchar(node.Data);
if fileexists(tmps) then
image1.Picture.LoadFromFile(tmps);
end;
end.