Форум: "Система";
Текущий архив: 2004.01.20;
Скачать: [xml.tar.bz2];
ВнизИконки в ХР Найти похожие ветки
← →
Tik (2003-11-06 17:35) [0]Вот код: ((- в 98-ом --- все ОК! Но в ХР иконок нету.))
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, FileCtrl, ComCtrls,ShellAPI;
type
TForm1 = class(TForm)
ListView1: TListView;
DirectoryListBox1: TDirectoryListBox;
ComboBox1: TComboBox;
DriveComboBox1: TDriveComboBox;
procedure FormCreate(Sender: TObject);
procedure DirectoryListBox1Change(Sender: TObject);
procedure ComboBox1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure UpdateFiles;
var
sr: TSearchRec;
li: TListItem;
fi: TSHFileInfo;
ext: string;
IconIndex: word;
ic: TIcon;
begin
Form1.ListView1.Items.BeginUpdate;
Form1.ListView1.Items.Clear;
if FindFirst(Form1.DirectoryListBox1.Directory + "\*.*", faAnyFile, sr) = 0 then repeat
if sr.Attr and faDirectory <> 0 then continue;
li := Form1.ListView1.Items.Add;
li.Caption := sr.Name;
ext := LowerCase(ExtractFileExt(li.Caption));
ShGetFileInfo(PChar("*" + ext), 0, fi, SizeOf(fi),
SHGFI_SMALLICON or SHGFI_SYSICONINDEX or SHGFI_TYPENAME);
li.ImageIndex := fi.iIcon;
if sr.Size < 1024
then li.SubItems.Add(IntToStr(sr.Size) + " byte")
else if sr.Size < 1024 * 1024
then li.SubItems.Add(IntToStr(round(sr.Size / 1024)) + " KByte")
else li.SubItems.Add(IntToStr(round(sr.Size / (1024 * 1024))) + " MByte");
li.SubItems.Add(fi.szTypeName);
until FindNext(sr) <> 0;
FindClose(sr);
Form1.ListView1.Items.EndUpdate;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
fi: TSHFileInfo;
lc: TListColumn;
begin
DriveComboBox1.DirList := DirectoryListBox1;
with ListView1 do begin
SmallImages := TImageList.CreateSize(16,16);
SmallImages.Handle := ShGetFileInfo("*.*", 0, fi,
SizeOf(fi), SHGFI_SMALLICON or SHGFI_ICON
or SHGFI_SYSICONINDEX);
LargeImages := TImageList.Create(nil);
LargeImages.Handle := ShGetFileInfo("*.*", 0, fi,
SizeOf(fi), SHGFI_LARGEICON or SHGFI_ICON
or SHGFI_SYSICONINDEX);
lc := Columns.Add;
lc.Caption := "Name";
lc := Columns.Add;
lc.Caption := "Size";
ComboBox1.Items.Add("Icons");
ComboBox1.Items.Add("List");
ComboBox1.Items.Add("Table");
ComboBox1.Items.Add("SmallIcons");
ComboBox1.ItemIndex := 0;
end;
UpdateFiles;
end;
procedure TForm1.DirectoryListBox1Change(Sender: TObject);
begin
UpdateFiles;
end;
procedure TForm1.ComboBox1Click(Sender: TObject);
begin
case ComboBox1.ItemIndex of
0: ListView1.ViewStyle := vsIcon;
1: ListView1.ViewStyle := vsList;
2: ListView1.ViewStyle := vsReport;
else ListView1.ViewStyle := vsSmallIcon;
end;
end;
Вчем проблема???
← →
Woodpecker (2003-11-06 18:55) [1]В ДНК.
Страницы: 1 вся ветка
Форум: "Система";
Текущий архив: 2004.01.20;
Скачать: [xml.tar.bz2];
Память: 0.45 MB
Время: 0.012 c