Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Graphich in listview

Posted on 1999-07-26
4
Medium Priority
?
208 Views
Last Modified: 2010-04-04
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....
0
Comment
Question by:mladenb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 1391323
Try this component. Source is included.

http://home.t-online.de/home/merkes/dirtree.zip


Regards,

Epsylon.

0
 
LVL 17

Expert Comment

by:inthe
ID: 1391324
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_ATTACHED then
  begin
     application.messagebox('Attach 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(hInstance, pchar(AttachFileName), x); // Part 1 of the trick
     Image1.Picture.Icon.Handle := HI;
     MyIconIndex := ImageList1.addIcon(Image1.picture.icon); // MyIconIndex is Part 2 of the trick
     IconItem := ListView1.Items.Add;    
     IconItem.caption := ExtractFileName(AttachFileName);
     IconItem.SubItems.add(AttachFileName);
     IconItem.imageindex := MyIconIndex; // Here! The magic is done!
  end;
end;

Regards Barry
0
 
LVL 17

Accepted Solution

by:
inthe earned 200 total points
ID: 1391325
The full unit would look like this:

unit Unit1;

interface

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

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

var
  Form1: TForm1;

implementation

{$R *.DFM}

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;
  if ListView1.Items.Count>=MAX_FILES_ATTACHED then
  begin
     application.messagebox('Attach 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(hInstance, pchar(AttachFileName), x);
     Image1.Picture.Icon.Handle := HI;
     MyIconIndex := ImageList1.addIcon(Image1.picture.icon);
     IconItem := ListView1.Items.Add;
     IconItem.caption := ExtractFileName(AttachFileName);
     IconItem.SubItems.add(AttachFileName);
     IconItem.imageindex := MyIconIndex;
   end;
 end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Image1.Visible:=False;
Listview1.SmallImages:=ImageList1;
Listview1.ViewStyle:=vsSmallIcon;
end;

end.


is that what you were after?
Regards Barry
0
 

Author Comment

by:mladenb
ID: 1391326
Nice code... Thank you very much...
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Suggested Courses

662 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question