这是一个相对来说比较难的问题(对我而言),望能得到大虾的指点!

chrisz 2001-02-26 08:45:00
用一个“Button”和“OpenDialog”能很容易得将选中的文件打开到“ListBox”中,现我想用一个“Button”和“OpenDialog”将选中的文件打开到“ListView”中。原因很简单:“ListView”能将文件以“大图标”、“小图标”、“详细资料”等格式显示文件,而“ListBox”不能。我用了WIN API函数:“GetFileAttributes”等(凡是关于“GetFile...”的)都试过了,但全不行。毕竟我水平有限,菜鸟一个。没办法了,只能上网求助!
...全文
70 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Kingron 2001-02-26
  • 打赏
  • 举报
回复
至于取得文件的其他的信息,我想很简单,就自己看看吧,实在还有不懂地方,贴出来。
Kingron 2001-02-26
  • 打赏
  • 举报
回复
仔细看看吧:
调试通过的。
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ImgList, ComCtrls,shellapi, ExtCtrls;

type
TForm1 = class(TForm)
ListView1: TListView;
ImageList1: TImageList;
Button1: TButton;
OpenDialog1: TOpenDialog;
Image1: TImage;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
info:_shfileinfoa;
item:tlistitem;
begin
if OpenDialog1.Execute then
begin
for i:=0 to OpenDialog1.Files.Count-1 do
begin
SHGetFileInfo(pchar(OpenDialog1.Files.Strings[i]),0,info,sizeof(info),SHGFI_ICON+SHGFI_LARGEICON);
image1.Picture.Icon.Handle:=info.hIcon;
imagelist1.AddIcon(image1.Picture.Icon);
item:=listview1.Items.Add;
item.ImageIndex:=i;
item.Caption:=extractfilename(OpenDialog1.Files.Strings[i]);
end;
end;
end;

end.

5,392

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧