|
-
Sep 2nd, 2011, 01:10 PM
#1
Thread Starter
Member
Get the icons of all open windows displayed in the taskbar
I need to get the icons of all open windows that are displayed in the taskbar. I posted a previous thread similar to this in which I asked how to get a full file path from an hWnd number, but it turns out the solution in that thread is not going to work for me.
The solution in that thread was to use GetModuleFileName. After much experimentation and reading about GetModuleFileName I discovered that instead I would have to use GetModuleFileNameEx, which after hours of research I still haven't been able to find a working example of, nor do I know that it would work anyway as I've read threads on other forums where people have been unable to make these API's work for this situation. (Some info on why this wont work: A Thread, Info about Handles and Proccess IDs). According to those two links I would have to use process loops, which I have no idea how to do.
I also found this example which does almost what I'm wanting to do, but it only returns the path of the top level window and I'm at a loss on how to convert it to give me the path of windows that are not top level.
Just for clarification on what I'm trying to do, I'm creating my own custom version of the windows taskbar and I need to be able to extract the icons of all the open windows that are displayed in the real windows taskbar so I can put them on the simulated taskbar tabs.
I've been searching for days for a way to accomplish this but I'm not turning up anything that works. If anyone can point me in the right direction or give me ideas for alternative methods of going about doing this I would really appreciate it.
-
Sep 2nd, 2011, 01:16 PM
#2
Re: Get the icons of all open windows displayed in the taskbar
I assume you can already get the hWnds of the taskbar windows?
If so, SendMessage API using WM_GETICON can return the small/large icon used in that window. You can then draw the icon using DrawIconEx API or convert it to a stdPicture object (search this forum using key term: HandleToPicture).
Note: Not sure if the handle passed is actual handle or copy. If copy, you'll need to destroy it at some point.
Edited: Testing appears to show the icon is not a copy. If you will want a copy for your own purposes, use CopyImage API on the returned handle.
Last edited by LaVolpe; Sep 2nd, 2011 at 01:19 PM.
-
Sep 3rd, 2011, 04:11 PM
#3
Thread Starter
Member
Re: Get the icons of all open windows displayed in the taskbar
I hate to ask, but could you post an example of how this is done? I've spent the past 24 hours or so researching and trying everything I know to make it work but meeting with nothing but failure. I'd post examples of what I've tried but they would run on for pages lol.
Edit: And yes, I can the hWnd numbers.
-
Sep 3rd, 2011, 08:04 PM
#4
Re: Get the icons of all open windows displayed in the taskbar
Code:
Dim hIcon As Long
hIcon = SendMessage(targetHwnd, WM_GETICON, 0&, ByVal 0&) ' try small icon first
If hIcon = 0& Then
hIcon = SendMessage(targetHwnd, WM_GETICON, 1&, ByVal 0&) ' try large icon
End If
If hIcon = 0& Then
' do whatever, you are not getting the associated icon
Else
' you have an icon handle. do with what you need
End If
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|