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

Peter Ritchie <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.advanced
Message-ID <LISTSERV%[email protected]>
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

===================================
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.