ExtractAssociatedIcon and ListView

ExtractAssociatedIcon and ListView

Post by Adam O'Nei » Fri, 03 Sep 1999 04:00:00



I want to set up a ListView control so that when I drag files from Explorer
into it, the file(s) are added to the list, and the correct icon displays in
the ListView for each file.

I got the drag part, but the icon part I don't. What I'm doing is (--and I
don't know what I'm doing. I pieced my code together from Appleman's Win32
book and a project example from http://www.thescarms.com/index.htm):

- call ExtractAssociatedIcon using the file name dropped on the ListView.

- use the return value from ExtractAssociatedIcon in DrawIconEx to draw the
icon in a PictureBox.

- add a ListImage to a ImageList control, using the Image property of the
PictureBox.

The icons drawn in the picture box are coming out right, but they're all
32x32. I want 16x16. I don't know how to control this--between
ExtractAssociatedIcon and DrawIconEx. (I tried using 16 and 16 as the
dimensions in the DrawIconEx statement, but the results were 1/4 the size I
wanted...???) The icons I'm adding to my ListView are 32x32s squished to fit
16x16--instead of the real 16x16 icons.

I've read Appleman's book as much as I can stand it. It's a good book but
I'm stuck and want someone to just tell me the answer. ;-)

Thanks for any help,
Adam

 
 
 

ExtractAssociatedIcon and ListView

Post by Ben Brik » Tue, 07 Sep 1999 04:00:00


Hi Adam,

maybe I have a solution for your problem...

I haven't experience a lot yet with extracting icons, but I know you can
extract both the small and the large icon from a file with the
ExtractIconEx-function. That's not a solution, I know, because thisone
extracts from the file itsself and the files you mean probably won't have
their own icons with them, unless you can figure out in another function
where to extract the icons for a specific file.

But (there's always a but) when you take a look at the definition of the
ExtractAssociatedIcon-function, you see that the last variable specifies the
index of the icon. Maybe the next icon in the function (index + 1) is the
small icon (16x16). I'm not sure if this will work, but you can always
try...

Good luck,

    Ben Brik



Quote:> I want to set up a ListView control so that when I drag files from
Explorer
> into it, the file(s) are added to the list, and the correct icon displays
in
> the ListView for each file.

> I got the drag part, but the icon part I don't. What I'm doing is (--and I
> don't know what I'm doing. I pieced my code together from Appleman's Win32
> book and a project example from http://www.thescarms.com/index.htm):

> - call ExtractAssociatedIcon using the file name dropped on the ListView.

> - use the return value from ExtractAssociatedIcon in DrawIconEx to draw
the
> icon in a PictureBox.

> - add a ListImage to a ImageList control, using the Image property of the
> PictureBox.

> The icons drawn in the picture box are coming out right, but they're all
> 32x32. I want 16x16. I don't know how to control this--between
> ExtractAssociatedIcon and DrawIconEx. (I tried using 16 and 16 as the
> dimensions in the DrawIconEx statement, but the results were 1/4 the size
I
> wanted...???) The icons I'm adding to my ListView are 32x32s squished to
fit
> 16x16--instead of the real 16x16 icons.

> I've read Appleman's book as much as I can stand it. It's a good book but
> I'm stuck and want someone to just tell me the answer. ;-)

> Thanks for any help,
> Adam


 
 
 

1. ExtractAssociatedIcon

Hi

I've just started using API calls. I used ExtractIcon
(copied straight out of a book) and got the expected
result. Then I tried to use ExtractAssociatedIcon using
the following code.

Declare Function MyExtractAssociatedIcon Lib "shell32.dll"
Alias "ExtractAssociatedIcon" _
        (ByVal hInst As Long, ByVal lpIconPath As String, _
            ByVal lpiIcon As Integer) As Long

Sub hIconToPicture()

Dim strIconFilePath As String
Dim hIcon As Long
Dim intLpiIcon As Integer

strIconFilePath = "C:\Program Files\Microsoft
Office\Office10\excel.exe"
intLpiIcon = 0

hIcon = MyExtractAssociatedIcon(0, strIconFilePath,
intLpiIcon)

Form1.Picture1.Picture = GPicTool.IconToPicture(hIcon)

End Sub

And VB returned the following error:

'453' Can't find DLL entry point ExtractAssociatedIcon in
shell32.dll

Is this because of syntax, logic .?

Thanks

2. Compiling SDL with BCB...

3. ExtractAssociatedIcon into ImageList?

4. slow x11perf on high impact

5. API: ExtractAssociatedIcon Error etc.

6. TDDBltFX type declaration in Delphi-Jedi translated headers error

7. ExtractAssociatedIcon

8. double y-axis

9. ExtractAssociatedIcon() to picture object?

10. ExtractAssociatedIcon

11. Something Like ExtractAssociatedIcon

12. ExtractAssociatedIcon