HighTechTalks DotNet Forums  

Application icon from hWnd?

Dotnet Framework (Drawing) microsoft.public.dotnet.framework.drawing


Discuss Application icon from hWnd? in the Dotnet Framework (Drawing) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Zamdrist
 
Posts: n/a

Default Application icon from hWnd? - 12-26-2007 , 08:45 AM






Is it possible to get a bitmap icon from a window's hWnd value
suitable for populating an ImageList control? I have working a small
application that lists the running, user applications in a listview
(title & hWnd) and it would be great if I could also add the icon (or
the parent's icon where appropriate) to the listview.

Thoughts, ideas or suggestions? Thanks...

Steve

Reply With Quote
  #2  
Old   
Duncan Jones
 
Posts: n/a

Default Re: Application icon from hWnd? - 12-26-2007 , 03:04 PM






If the Icon is there by way of the window class then the "GetClassLong " API
call passing GCL_ICON as the index will return it's handle - or you can send
a WM_GETICON message to the window and get the handle back
(See http://msdn2.microsoft.com/en-us/library/aa453863.aspx )

Hope this helps
Duncan Jones
"Zamdrist" <zamdrist (AT) gmail (DOT) com> wrote

Quote:
Is it possible to get a bitmap icon from a window's hWnd value
suitable for populating an ImageList control? I have working a small
application that lists the running, user applications in a listview
(title & hWnd) and it would be great if I could also add the icon (or
the parent's icon where appropriate) to the listview.

Thoughts, ideas or suggestions? Thanks...

Steve


Reply With Quote
  #3  
Old   
Duncan Jones
 
Posts: n/a

Default Re: Application icon from hWnd? - 12-26-2007 , 03:06 PM



If the Icon is there by way of the window class then the "GetClassLong " API
call passing GCL_ICON as the index will return it's handle - or you can send
a WM_GETICON message to the window and get the handle back
(See http://msdn2.microsoft.com/en-us/library/aa453863.aspx )

Hope this helps
Duncan Jones
"Zamdrist" <zamdrist (AT) gmail (DOT) com> wrote

Quote:
Is it possible to get a bitmap icon from a window's hWnd value
suitable for populating an ImageList control? I have working a small
application that lists the running, user applications in a listview
(title & hWnd) and it would be great if I could also add the icon (or
the parent's icon where appropriate) to the listview.

Thoughts, ideas or suggestions? Thanks...

Steve


Reply With Quote
  #4  
Old   
Zamdrist
 
Posts: n/a

Default Re: Application icon from hWnd? - 12-28-2007 , 09:37 AM



Thanks Duncan, but that function appears to only apply to Windows CE
1.0 or later, according to the documentation there in, MDSN.

On Dec 26, 3:06 pm, "Duncan Jones" <Dun... (AT) merrionomputing (DOT) com> wrote:
Quote:
If the Icon is there by way of the window class then the "GetClassLong " API
call passing GCL_ICON as the index will return it's handle - or you can send
a WM_GETICON message to the window and get the handle back
(Seehttp://msdn2.microsoft.com/en-us/library/aa453863.aspx)

Hope this helps

Reply With Quote
  #5  
Old   
Duncan Jones
 
Posts: n/a

Default Re: Application icon from hWnd? - 12-28-2007 , 10:02 AM



It also applies to all desktop OS versions post Windows 95 / NT4.0
http://msdn2.microsoft.com/en-us/lib...25(VS.85).aspx

Hope this helps,
Duncan

"Zamdrist" <zamdrist (AT) gmail (DOT) com> wrote

Quote:
Thanks Duncan, but that function appears to only apply to Windows CE
1.0 or later, according to the documentation there in, MDSN.

On Dec 26, 3:06 pm, "Duncan Jones" <Dun... (AT) merrionomputing (DOT) com> wrote:
If the Icon is there by way of the window class then the "GetClassLong "
API
call passing GCL_ICON as the index will return it's handle - or you can
send
a WM_GETICON message to the window and get the handle back
(Seehttp://msdn2.microsoft.com/en-us/library/aa453863.aspx)

Hope this helps


Reply With Quote
  #6  
Old   
Michael Phillips, Jr.
 
Posts: n/a

Default Re: Application icon from hWnd? - 12-28-2007 , 10:03 AM



Quote:
Thoughts, ideas or suggestions? Thanks...
Try this:
1) Use P-Invoke GetWindowThreadProcessId to give you a pid from the HWND
handle.
2) Use the System.Diagnostics.Process.GetProcessById along with the
ProcessName property to give you the application .exe name.
3) Use P-Invoke SHGetFileInfo to give you the default icon used for the
application.
the hIcon member of the SHFILEINFO structure provides a handle to the
icon
which you may use with your image list control.


"Zamdrist" <zamdrist (AT) gmail (DOT) com> wrote

Quote:
Is it possible to get a bitmap icon from a window's hWnd value
suitable for populating an ImageList control? I have working a small
application that lists the running, user applications in a listview
(title & hWnd) and it would be great if I could also add the icon (or
the parent's icon where appropriate) to the listview.

Thoughts, ideas or suggestions? Thanks...

Steve



Reply With Quote
  #7  
Old   
Zamdrist
 
Posts: n/a

Default Re: Application icon from hWnd? - 12-28-2007 , 10:27 AM



Thank you Duncan

Forgive me, but I'm hobbling this together with a limited knowledge of
how this will work. My advanced knowledge of VB.Net and using the
Win32 API is limited.

It appears as though I would use the function WindowProc() and
WM_GETICON as one of the parameters inorder to get back a handle to
the icon, for adding to to the ImageList (presuming there's a way to
populate the image list using the icon's handle value)

Documentation and good examples are sparse and scattered all over the
net, and I'm not quite sure how'd I go about this. I already am using
GetWindowPlacement, SetWindowPlacement API functions, so I'm not
*completely* clueseless :-S

Thanks...

On Dec 28, 10:02 am, "Duncan Jones" <Dun... (AT) merrionomputing (DOT) com>
wrote:
Quote:
It also applies to all desktop OS versions post Windows 95 / NT4.0http://msdn2.microsoft.com/en-us/library/ms632625(VS.85).aspx

Hope this helps,
Duncan

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.