[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool EnumChildWindows(IntPtr hwndParent, EnumWindowsProc lpEnumFunc, IntPtr lParam);
public delegate bool Win32Callback(IntPtr hwnd, IntPtr lParam);
[DllImport("user32.Dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern IntPtr EnumChildWindows(IntPtr parentHandle, Win32Callback callback,IntPtr lParam);
<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
Private Shared Function EnumChildWindows(ByVal hWndParent As System.IntPtr, _
ByVal lpEnumFunc As EnumWindowsProc, ByVal lParam As Integer) As Boolean
' Leave function empty
End Function
None.
Please add some!
if(!isIEServerWindow(windowHandle))
{
//Get 1st child IE server window
Win32.EnumChildWindows(windowHandle, new Win32Callback(this.EnumChild), windowHandle);
}
private bool EnumChild(IntPtr hWnd,IntPtr lParam)
{
if(isIEServerWindow(hWnd) )
{
lParam = hWnd;
}
else
{
return true;
}
return false;
}
private static bool isIEServerWindow(IntPtr hWnd)
{
IntPtr Res;
StringBuilder ClassName = new StringBuilder(100);
//Get the window class name
Res = Win32.GetClassName(hWnd, ClassName, ClassName.MaxCapacity);
if(Res != IntPtr.Zero)
{
return (string.Compare(ClassName.ToString(), "Internet Explorer_Server",true,CultureInfo.InvariantCulture) == 0);
}
else
{
return false;
}
}
http://www.vbaccelerator.com/home/NET/Code/Libraries/Windows/Enumerating_Windows/article.asp has a nice article
Do you know one? Please contribute it!