Actually Process.MainWindowHandle is a handle of top-most window, it's not really the "Main Window Handle"
aku
2008-09-07 10:39:22
Actually Process.MainWindowHandle is a handle of top-most window, it's not really the "Main Window Handle"
@edg,
I guess it's an error in MSDN. You can clearly see in Relfector, that "Main window" check in .NET looks like:
private bool IsMainWindow(IntPtr handle)
{
return (!(NativeMethods.GetWindow(new HandleRef(this, handle), 4) != IntPtr.Zero)
&& NativeMethods.IsWindowVisible(new HandleRef(this, handle)));
}
When .NET code enumerates windows, it's pretty obvious that first visible window (i.e. top level window) will match this criteria.