Re: Determining if a process is visible on the Taskbar...

Mike Andrews <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.advanced
Message-ID <[email protected]>
Peter,

I gave your code a try and it partially works.  It seems that not all
top-level windows (that have a taskbar button) have the WS_EX_APPWINDOW
style bit set.  I used Spy++ to verify this.  Firefox is one of them.

The previous suggestion from Zac partially works as well.  Using the
intersection between all the Processes on the system and the enumeration of
all the windows compared on the Process.MainWindowHandle to the handled
returned by the EnumWindows method yields most of the top-level visible
application windows.

I'm not sure there is a clear-cut solution to this problem.  Nevertheless,
I'll keep hacking away at it.
Thank you for the example code.
Thanks to Zac as well for his code.

Thanks,
Mike

On Mon, Nov 24, 2008 at 9:38 AM, Peter Ritchie <
[email protected]> wrote:

> Theoretically, it should just be a matter of testing all the window's
> WS_EX_APPWINDOW [1] extended style bit.  EnumWindows, as someone suggested
> is a good way to do this.  For example:
>
> private delegate bool EnumWindowProc(IntPtr hwnd, int lParam);
> [DllImport("user32.dll")]
> private static extern int EnumWindows(EnumWindowProc callPtr, int lPar);
>
> public void TraceProcessTaskBarWindows()
> {
>        const int MagicNumber = 10;
>        const int GWL_EXSTYLE = -20;
>        const int WS_EX_APPWINDOW = 0x40000;
>        EnumWindows(delegate(IntPtr hwnd, int lParam)
>                        {
>                                                if(lParam != MagicNumber)
> return true;
>                                                IntPtr exStyle =
> GetWindowLong(new HandleRef(this, hwnd), GWL_EXSTYLE);
>                                                if (((int)exStyle &
> WS_EX_APPWINDOW) == WS_EX_APPWINDOW)
>                                                {
>
>  Trace.WriteLine("Found window in task bar");
>                                                }
>                                return true;
>
>                        }, MagicNumber);
>        return;
> }
>
> [1] http://msdn.microsoft.com/en-us/library/ms632680(VS.85).aspx<http://msdn.microsoft.com/en-us/library/ms632680%28VS.85%29.aspx>
>
> ===================================
> View archives and manage your subscription(s) at
> http://peach.ease.lsoft.com/archives
>

===================================
View archives and manage your subscription(s) at http://peach.ease.lsoft.com/archives
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.