请问怎样像ACDSEE那样可以显示上一张、下一张图片?(100分)

  • 主题发起人 主题发起人 石斑鱼
  • 开始时间 开始时间

石斑鱼

Unregistered / Unconfirmed
GUEST, unregistred user!
请问怎样像ACDSEE那样可以显示上一张、下一张图片?
俺用ImageEn想模仿ACDSee做一个图像浏览器,怎样能实现按下按钮就能看上一张、下一张图片?
 
用 FindFirst/FindNextFile/FindClose 建立当前目录的文件列表。
 
传过来一个当前目录
filelist:tstringlist;
procedure TForm1.readimage(path: string);
var found:integer;
ser:tsearchrec;
str:string;
i:integer;
path1:string;
begin
namelist:=tstringlist.Create ;
filelist:=tstringlist.Create ;
filelist.Clear;
filelist.Clear;
path1:=path+'*.*';
found:=findfirst(path1,faAnyFile,ser);
while found=0 do
begin
str:=lowercase(extractfileext(ser.Name));
if( str='.bmp' )or(str='.jpg' )or (str='.jpeg' ) then
begin
filelist.Add(path+ser.Name ); ///记录所有后缀为bmp,jpg,jpeg
end;
found:= findnext(ser);
end;
findclose(ser);
end;
然后用TIimageList 来添加filelist中的文件就可以了
str:=lowercase(extractfileext(namelist.Strings)) ;
///////////////
if str='.bmp' then
begin
image1.Picture.LoadFromFile(filelist.Strings);
bitmap.Canvas.StretchDraw(rect(20,20,70,70),image1.Picture.Bitmap );
imagelist1.Add(bitmap,nil);
bitmap.Free;
end;
///////////////////
/////JPG¸ñʽÎļþ¡£
if( str='.jpg')or (str='.jpeg') then
begin
tempbitmap:=tbitmap.Create;
jpg:=tjpegimage.Create;
jpg.LoadFromFile(filelist.Strings);
tempbitmap.Assign(jpg);
bitmap.Canvas.StretchDraw(rect(20,20,70,70), tempbitmap );
imagelist1.Add(bitmap ,nil);
end;
 
可不可以具体一些,小弟愚笨
 
上面的代码好像不太好用耶
 
刚写了一段代码获取文件列表,已测试。
procedure TForm1.Button1Click(Sender: TObject);
var
FileHandle: THandle;
FindFileData: TWin32FindData;
FileFound: Boolean;
begin
FileHandle := FindFirstFile('C:/WINDOWS/*.BMP', FindFileData);
FileFound := FileHandle <> INVALID_HANDLE_VALUE;
if not FileFound then
begin
ShowMessage('错误!');
Exit;
end
else begin
repeat
Memo1.Lines.Add(FindFileData.cFileName);
FileFound := FindNextFile(FileHandle, FindFileData);
until (not FileFound);
end;
Windows.FindClose(FileHandle);
end;
 
多人接受答案了。
 
后退
顶部