Displaying Windows from the Taskbar

Started by
22 comments, last by Colin Jeanne 14 years, 11 months ago
Well recently, for testing purposes I created a program that displays the programs that are in the task bar. Or so I tried. What I attempted to do was to use EnumWindows() to go through all the windows and list them in my list box. But I ended up with EVERY window (not child windows), for example invisible windows which are not displayed on the Taskbar. I then tried to filter the results by using IsWindowVisible() but I still ended up with windows that weren't on the Taskbar. So my question is, "How do I only list windows that are on the Taskbar in my list box? and not child, invisible or any other sort of window?". Thank you. EDIT - Please go down as the subject of the thread has been changed from "Displaying Windows from the Taskbar" to "Using 'Modern style' Controls", thank you :D. [Edited by - VirtualProgrammer on May 9, 2009 7:38:14 AM]
Advertisement
This should help ya.

Example of working with the Taskbar

theTroll

[Edited by - TheTroll on May 4, 2009 12:21:56 PM]
hanks for the quick reply :D. But the link has no life (a.k.a. its dead). I await your reply :).
Fixed the link.

theTroll
Hmm, the example searches for the Task Bar and then sees the programs that are on it. That does partly answer my question, but what I need is the algorithm used by the Task Bar to find the correct windows to list. So basically, how is it that the Task Bar can tell what programs it needs to display? what method is used?

Thank you :).
Believe you are looking for WS_EX_APPWINDO set to true.

theTroll
See the last post here, it's the algorithm described here taking into account the described caveats.
theTroll: Thanks but I'm not sure looking for that style will work :).
adeyblue: Hmm thanks :D Your method sure seems to work nicely! But since I didn't understand some of the functions that you used I decided to do 'it' using another method. And the following seems to work great!:

if(IsWindowVisible(DesktopName) == TRUE && GetParent(DesktopName) == NULL && GetWindowLongPtr(DesktopName, GWL_STYLE) & WS_CAPTION) { GetWindowText(DesktopName, WNDTitle, 100); SendMessage(DesktopsListLB, LB_ADDSTRING, NULL, (LPARAM)WNDTitle); }


Is there anything wrong with using this method? for example, certain windows that should be detected that won't be.

Thank you.
I'm guessing DesktopName is the window handle you're testing? That's a really bad name for that variable if that's the case (it's not a "name" and it's not the "desktop" either, hwnd is a pretty standard variable name for miscellaneous window handles).

Anyway, you've also got to test for the WS_EX_APPWINDOW and WS_EX_TOOLWINDOW extended window styles. Basically, WS_EX_APPWINDOW windows will always appear in the taskbar, even if they have an owner, and WS_EX_TOOLWINDOW windows will not appear in the taskbar even if they don't have an owner.

See MSDN for more details.
Oh haha, that variable naming thing you're talking about was kind of an accident. Basically I already had another one of my tests up and running (it was to do with desktops :)) so I just quickly changed it around to see how window enumerating works.

Oh so that's why I need to look for them. Alright let me just implement that and give you the resulting code. Just to see if it is a good algorithm to use :).

This topic is closed to new replies.

Advertisement