如何使用samples中的shelllistview控件实现图片预览? (200分)

  • 主题发起人 咪咪猫
  • 开始时间

咪咪猫

Unregistered / Unconfirmed
GUEST, unregistred user!
我用image控件和shelllistview控件
想通过点击shelllistview中的图片图标使在image控件中显示该图片
但不知道shelllistview控件如何使用
我用image1.picture.loadFormfile(filename)
filename应该和shelllistview控件如何关联?
希望各位高手尽快答复,小弟感激不尽![8D]
 
//这样写试试看 ,试着多研究研究shellctrls.pas
procedure TForm1.ShellListView1Change(Sender: TObject; Item: TListItem;
Change: TItemChange);
begin
try
inherited;
Image1.Picture.LoadFromFile(ShellListView1.SelectedFolder.PathName);
except
end;
end;
//运行编译好的程序不会出错,你还可以进一步优化。比如说判断后缀名,给分吧。^_*
 
谢谢你的答复
再问一下该如何判别后缀
我想能够看jpg,gif等其他格式,不只是bmp格式
回答后给200分
 
procedure Tmainform.ShellListView1Change(Sender: TObject; Item: TListItem;
Change: TItemChange);
var filename:string;
begin
filename:=shelllistview1.Selectedfolder.PathName;
if ExtractFileExt(filename)<>'.bmp' then
showmessage('cat')
else
begin
try
inherited;
image1.Picture.LoadFromFile(shelllistview1.Selectedfolder.PathName);
except
end
end
end;
我这样做好像会出错,不知道为什么,请指教^_^
 
procedure TForm1.ShellListView1Change(Sender: TObject; Item: TListItem;
Change: TItemChange);
var
Ext,filename:string;
i:integer;
begin
try
filename:=shelllistview1.Selectedfolder.PathName;
Ext:=ExtractFileExt(filename);
for i:=2 to length(Ext) do
Ext:=upcase(Ext);
if (Ext<>'.BMP') and (Ext<>'.JPG') then
exit
else
begin
try
image1.Picture.LoadFromFile(filename);
except
end
end
except
end;
end;
//gif格式 delphi的image支持起来有困难,最好去找一个第三方控件,cakk.126.com就有.
别的就真不知道了,ShellListView也没怎么用过,自己多动动脑筋吧。ok
 
奇怪,为什么按照上面所说的,当点击第一个bmp图标的时候没错,但当点击第二个bmp图标或别的地方的时候就出错了
 
我想让ShellListView过滤显示出*.bmp格式的????
好象不能。
 
为什么老是出错,有没有这个控件的资料啊?
 
哎,资料就是shellctrls.pas。
其实你用win31下的FileListBox和DirectoryListBox多省力气,
过滤文件也好办。
 
接受答案了.
 
顶部