如何将某一个目录下的所有的图片文件作一个缩略浏览,就像ACDSee中的那样? 如何将某一个目录下的所有的图片文件作一个缩略浏览,就像ACDSee中的那样?请指点 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 参考以下程序:unit Unit1;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls,StdCtrls,jpeg,FileCtrl;type TForm1 = class(TForm) DriveComboBox1: TDriveComboBox; DirectoryListBox1: TDirectoryListBox; ScrollBox1: TScrollBox; procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure DirectoryListBox1Change(Sender: TObject); private { Private declarations } public { Public declarations } end;//私有类声明type tbi_thumb=class(TCustomcontrol) fmypic : TJpegImage; private procedure getpic(value:tjpegimage); public procedure paint; override; constructor Create(AOwner:TComponent); override; destructor Destroy; override; published property pic:tjpegimage write getpic;end;var Form1: TForm1;implementation{$R *.DFM}var buffer_jpeg:tjpegimage;constructor tbi_thumb.create(aowner:tcomponent);begin inherited; fmypic:=tjpegimage.create;end;destructor tbi_thumb.destroy;begin inherited; fmypic.free;end;procedure tbi_thumb.getpic(value:tjpegimage);begin fmypic.scale:=jshalf; fmypic.assign(value); fmypic.dibneeded;end;procedure tbi_thumb.paint;var arect : trect;begin arect:=clientrect; canvas.stretchdraw(arect,fmypic); frame3d(canvas,arect,clblack,clwhite,2);end;procedure TForm1.FormCreate(Sender: TObject);begin buffer_jpeg:=tjpegimage.create; buffer_jpeg.Performance:=jpbestspeed;end;procedure TForm1.FormDestroy(Sender: TObject);begin buffer_jpeg.free; while scrollbox1.ComponentCount>0 do scrollbox1.components[0].free;end;procedure TForm1.DirectoryListBox1Change(Sender: TObject);var i,x,y : integer; anewthumb : tbi_thumb; foundlist : tstringlist; sr : TSearchRec;begin foundlist:=tstringlist.create; //查找图象文件 try if FindFirst(directorylistbox1.Directory+'\*.jpg', faAnyFile, sr) = 0 then begin foundlist.add(sr.name); while FindNext(sr) = 0 do foundlist.add(sr.name); FindClose(sr); end; x:=0; y:=0;//创建缩略图 for i:=0 to FoundList.count-1 do begin anewthumb:=tbi_thumb.create(self); buffer_jpeg.loadfromfile(foundlist[i]); with anewthumb do begin pic:=buffer_jpeg; parent:=scrollbox1; left:=x; top:=y; width:=120; height:=90; visible:=true; inc(x,122); if x>244 then begin x:=0; inc(y,92); end; application.processmessages; end; end; finally foundlist.free; end;end;end. 可不可以image.stretch:=true ,部 image 放置小点.. 使用spcomm中串口发生的问题 做了一段时间COM程序,还是不清楚COM与DLL的优势在哪? 第一次开贴,就是散分,大家来接过个好年吧!呵呵 excel导入到sql中 我求大家了!!! 江湖救急,在线等待:listView中的显示item,如何设置每项item的尺寸大小,用多行文字描述该item 请教大虾Adotable state的问题 各位大哥:请问一个Delphi工程中各个文件的意义 help!数据表 到这个地方下载Delphi下的加密利器cipher控件(带源码)。 linux 安装问题如下。。。。 如何做到象Delphi中一样代码一边写一边着色?
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls,StdCtrls,jpeg,FileCtrl;type
TForm1 = class(TForm)
DriveComboBox1: TDriveComboBox;
DirectoryListBox1: TDirectoryListBox;
ScrollBox1: TScrollBox;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure DirectoryListBox1Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;//私有类声明
type
tbi_thumb=class(TCustomcontrol)
fmypic : TJpegImage;
private
procedure getpic(value:tjpegimage);
public
procedure paint; override;
constructor Create(AOwner:TComponent); override;
destructor Destroy; override;
published
property pic:tjpegimage write getpic;
end;var
Form1: TForm1;implementation{$R *.DFM}var
buffer_jpeg:tjpegimage;constructor tbi_thumb.create(aowner:tcomponent);
begin
inherited;
fmypic:=tjpegimage.create;
end;destructor tbi_thumb.destroy;
begin
inherited;
fmypic.free;
end;procedure tbi_thumb.getpic(value:tjpegimage);
begin
fmypic.scale:=jshalf;
fmypic.assign(value);
fmypic.dibneeded;
end;procedure tbi_thumb.paint;
var
arect : trect;
begin
arect:=clientrect;
canvas.stretchdraw(arect,fmypic);
frame3d(canvas,arect,clblack,clwhite,2);
end;procedure TForm1.FormCreate(Sender: TObject);
begin
buffer_jpeg:=tjpegimage.create;
buffer_jpeg.Performance:=jpbestspeed;
end;procedure TForm1.FormDestroy(Sender: TObject);
begin
buffer_jpeg.free;
while scrollbox1.ComponentCount>0 do
scrollbox1.components[0].free;
end;procedure TForm1.DirectoryListBox1Change(Sender: TObject);
var
i,x,y : integer;
anewthumb : tbi_thumb;
foundlist : tstringlist;
sr : TSearchRec;
begin
foundlist:=tstringlist.create;
//查找图象文件
try
if FindFirst(directorylistbox1.Directory+'\*.jpg', faAnyFile, sr) = 0 then
begin
foundlist.add(sr.name);
while FindNext(sr) = 0 do
foundlist.add(sr.name);
FindClose(sr);
end;
x:=0;
y:=0;
//创建缩略图
for i:=0 to FoundList.count-1 do
begin
anewthumb:=tbi_thumb.create(self);
buffer_jpeg.loadfromfile(foundlist[i]);
with anewthumb do
begin
pic:=buffer_jpeg;
parent:=scrollbox1;
left:=x;
top:=y;
width:=120;
height:=90;
visible:=true;
inc(x,122);
if x>244 then
begin
x:=0;
inc(y,92);
end;
application.processmessages;
end;
end;
finally
foundlist.free;
end;
end;end.