mladenb
asked on
Graphich in listview
I want to put line in ListView with file name and icons wich is belong to that kind of file in Win98, eg. winword icon and blabla.doc
Thanx....
Thanx....
i thought he wanted something like this:
from alex's posting a while ago
add shlobj and shellapi to the uses
pu a image1 on the form(can be set to visible false)
procedure TForm1.Button1Click(Sender : TObject);
var
HI : THandle;
MyIconIndex : word;
IconItem : TListItem;
AttachFileName : string;
X : word;
MAX_FILES_ATTACHED : integer;
begin
MAX_FILES_ATTACHED := 12;
// This routine shows how to implement dynamic ImageLists with icons.
// The ListView is bound to the hidden ImageList, which in turn gets its
// icons from the hidden TImage. The hidden TImage gets an icon handle from
// ExtractAssociatedIcon. That's all it takes !
if ListView1.Items.Count>=MAX _FILES_ATT ACHED then
begin
application.messagebox('At tach file', 'Maximum number of file attachments reached.', MB_ICONEXCLAMATION + MB_OK);
exit;
end;
x := 0;
if OpenDialog1.execute then
begin
AttachFileName := expandfilename(OpenDialog1 .Filename) ;
HI := ExtractAssociatedIcon(hIns tance, pchar(AttachFileName), x); // Part 1 of the trick
Image1.Picture.Icon.Handle := HI;
MyIconIndex := ImageList1.addIcon(Image1. picture.ic on); // MyIconIndex is Part 2 of the trick
IconItem := ListView1.Items.Add;
IconItem.caption := ExtractFileName(AttachFile Name);
IconItem.SubItems.add(Atta chFileName );
IconItem.imageindex := MyIconIndex; // Here! The magic is done!
end;
end;
Regards Barry
from alex's posting a while ago
add shlobj and shellapi to the uses
pu a image1 on the form(can be set to visible false)
procedure TForm1.Button1Click(Sender
var
HI : THandle;
MyIconIndex : word;
IconItem : TListItem;
AttachFileName : string;
X : word;
MAX_FILES_ATTACHED : integer;
begin
MAX_FILES_ATTACHED := 12;
// This routine shows how to implement dynamic ImageLists with icons.
// The ListView is bound to the hidden ImageList, which in turn gets its
// icons from the hidden TImage. The hidden TImage gets an icon handle from
// ExtractAssociatedIcon. That's all it takes !
if ListView1.Items.Count>=MAX
begin
application.messagebox('At
exit;
end;
x := 0;
if OpenDialog1.execute then
begin
AttachFileName := expandfilename(OpenDialog1
HI := ExtractAssociatedIcon(hIns
Image1.Picture.Icon.Handle
MyIconIndex := ImageList1.addIcon(Image1.
IconItem := ListView1.Items.Add;
IconItem.caption := ExtractFileName(AttachFile
IconItem.SubItems.add(Atta
IconItem.imageindex := MyIconIndex; // Here! The magic is done!
end;
end;
Regards Barry
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Nice code... Thank you very much...
http://home.t-online.de/home/merkes/dirtree.zip
Regards,
Epsylon.