Getting a windows hIcon (Icon Handle)

Getting a windows hIcon (Icon Handle)

Post by Aaron Abd » Sat, 28 Nov 1998 04:00:00



If i know the hWnd of a window, how can i go about getting the hIcon for
that window?

I think the way is through GetClassInfoEx, is this right?? The only problem
then becomes, GetClassInfoEx needs the hInstance of the window. So how do i
go about getting that?

Any help on this would be greatly appreciated. TIA -

Aaron


 
 
 

Getting a windows hIcon (Icon Handle)

Post by Klaus H. Probs » Sun, 29 Nov 1998 04:00:00


Try this:

Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As
Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const WM_GETICON As Long = &H7F

Dim hIcon as Long

hIcon = SendMessage(hWnd, WM_GETICON, 1, ByVal 0&)

This will retreive the big icon (usually 32x32) for the window identified by hWnd... pass
0 instead of 1 in wParam to get the small icon.

~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please post/reply to the newsgroup(s) so
that everyone can benefit from the discussion.

Regards,

Klaus H. Probst, MCP


       ICQ: 22454937
~~~~~~~~~~~~~~~~~~~~~~~~~~~



> If i know the hWnd of a window, how can i go about getting the hIcon for
> that window?

> I think the way is through GetClassInfoEx, is this right?? The only problem
> then becomes, GetClassInfoEx needs the hInstance of the window. So how do i
> go about getting that?

> Any help on this would be greatly appreciated. TIA -

> Aaron




 
 
 

1. getting a StdPicture (BMP) for a HICON (Icon Handle)

I have a handle to an icon loaded from a file (let's say WORD, de document
icon). what i need now is a StdPicture Object which represents a BMP
containing that Icon i got the handle for. I need this StdPicture for the
API function SetMenuItemBitmaps 'cause i want to insert the icon into a
menu.
What i tryed is to load the icon into a picturebox and using the Picture
property of it for the function but that doesn't work. It works when i load
a BMP into to pictureBox and pass this to the SetMenuItemBitmaps function...

any ideas how i can manage the problem??

thank's
simon

2. Show Image With scroll bars

3. Getting a real window handle to an Image control

4. transparent backgrounds

5. A 24-bit icon window... getting BADMATCH

6. CosmoGL

7. Getting Windows icon for a file _type_, not from actual file

8. Publication repair. HELP!!!!!

9. Help need to change Mac Icons to Windows Icons

10. Windows icons to OpenGL icons

11. Problem converting Mac Icons to Windows Icon

12. Getting a handle on total RAM use

13. getting a handle on textures