// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; using System.Runtime.InteropServices; namespace e { public partial class MainForm : Form { public MainForm() { InitializeComponent(); } public delegate bool Win32Callback(IntPtr hwnd, IntPtr lParam); [DllImport("user32.Dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool EnumChildWindows(IntPtr parentHandle, Win32Callback callback,IntPtr lParam); public bool Show(IntPtr hwnd, IntPtr lParam) { MessageBox.Show(hwnd.ToInt64().ToString()); return true; } public void Button1Click(object sender, EventArgs e) { EnumChildWindows(this.Handle, Show, IntPtr.Zero); } } }