Bonjour a tous et a toutes ..
Je veux écrire une toute petit application qui contient un bouton, un listview et un composant zip master ..
Lorsque j'essaie d'afficher le contenu d'un fichier zip et les lister sur le Listview avec les icônes et le type du fichier associer par le shell (un peu comme Winrar ou Winzip) ca marche , mais il est lourd (le listview) alors je demande si quelqu'un a une idée sur le comment on peux resoudre cette lourdeur.
voici un fragment de code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
 
  TShInfoRec = record
     ico: HICON ;
     info: string ;
  end;
 
var
  Form1: TForm1;
 
 
 
 
implementation
 
{$R *.dfm}
 
function GetShellIcon(const fname: string): TShInfoRec;
var
  sfi: SHFileInfo ;
  tr: TShInfoRec ;
begin
  FillChar(sfi,SizeOf(sfi),'0');
  SHGetFileInfo(PChar(fname),0,sfi,SizeOf(sfi),
        SHGFI_ICON or SHGFI_USEFILEATTRIBUTES or SHGFI_TYPENAME )  ;
  tr.ico:= sfi.iIcon ;
  tr.info:= sfi.szTypeName;
  Result:= tr;
 
end;
 
function GetShellType(const fname: string): string;
begin
 
end;
 
 
procedure TForm1.FormCreate(Sender: TObject);
var
  FileInfo: TSHFileInfo;
  ImageListHandle: THandle;
begin
  ImageListHandle := SHGetFileInfo('', 0, FileInfo, SizeOf(FileInfo),
     SHGFI_SYSICONINDEX or SHGFI_SMALLICON);
  SendMessage(lv1.Handle, LVM_SETIMAGELIST, LVSIL_SMALL, ImageListHandle);
end;
 
procedure TForm1.btn1Click(Sender: TObject);
var
  I: Integer;
  cnt : Integer ;
  Item : TListItem ;
  t1: Cardinal ;
  inf:TShInfoRec;
 
begin
 
  Zm.ZipFileName := cbb1.Text ;
  cnt := Zm.Count ;
  //t1 := GetTickCount ;
 
  lv1.Items.Count := cnt
//  for I := 0 to cnt - 1 do    // Iterate
//  begin
//    Item := lv1.Items.Add();
//    with Item do
//    begin
//      Caption := ExtractFileName(Zm.DirEntry[I].FileName);
//
//      inf := GetShellIcon(Zm.DirEntry[I].FileName);
//      ImageIndex := inf.ico ;
//
//
//
//      SubItems.Add(IntToStr(Zm.DirEntry[I].UncompressedSize));
//      SubItems.Add(IntToStr(Zm.DirEntry[I].CompressedSize));
//      SubItems.Add(ExtractFilePath(Zm.DirEntry[I].FileName));
//    end;    // with
//  end;    // for
 
  //ShowMessage(IntToStr(GetTickCount - t1));
 
end;
 
procedure TForm1.btn2Click(Sender: TObject);
begin
  //lv1.Clear ;
  lv1.Items.Count := 0
end;
 
procedure TForm1.lv1Data(Sender: TObject; Item: TListItem);
var
  i: Integer;
  inf : TShInfoRec;
begin
    i := Item.Index ;
    with Item do
    begin
      Caption := ExtractFileName(Zm.DirEntry[i].FileName);
 
      inf := GetShellIcon(Zm.DirEntry[i].FileName);
      ImageIndex := inf.ico ;
 
 
 
      SubItems.Add(IntToStr(Zm.DirEntry[i].UncompressedSize));
      SubItems.Add(IntToStr(Zm.DirEntry[i].CompressedSize));
      SubItems.Add(ExtractFilePath(Zm.DirEntry[i].FileName));
      SubItems.Add(inf.info);
    end;    // with
end;