views:

442

answers:

2

Hello. I'd like to know if it's possible to know if an external application has an window that is showing up on the taskbar. I have a program that sometimes shows up an error message and it appears on the taskbar. If I "close" the message, it will go invisible, but from what I've seen it still exists. So the only way for me to know if that window is visible and thus "clickable" is to check if it is being shown on the taskbar or not.

How can I do this?

Thanks

A: 

First use spy++ (shipped with visual studio) to find out class name, window name, and windows hierarchy. Hint: when the error message is on screen, run spy++, press Alt+F3, then Alt+D, then drug the finder tool onto the error message window, then press OK.

if the window is top-level (ie its parent is the desktop) then use FindWindow API.

if the window is not top level (ie its parent is some other window) then first use FindWindow to find the main window, then use FindWindowEx (possibly recursively) to search for that error message window.

Soonts
A: 

The documented COM interface to manage the taskbar is ITaskbarList, but it only allows you to add/delete buttons, you can't get a list existing buttons.

So, you have three options:

A) Go into undocumented land, find the taskbar and its child tab control or toolbar (changed from 2000 to XP) and look at its undocumented per item data (IIRC there is a open source change taskbar button order app out there with this info)

B) Check the styles of the window you care about (WS_VISIBLE and (no owner or WS_EX_APPWINDOW) and not WS_EX_TOOLWINDOW) or something along those lines

C) Hook/subclass the broken application

Anders