Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

enumchildwindows (user32)
 
.
Summary

C# Signature:

[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);

VB Signature:

<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

User-Defined Types:

EnumWindowsProc

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

    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

Alternative Managed API:

Do you know one? Please contribute it!

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Find References
Show Printable Version
Revisions