void HookChildControl(Control ctrl) { if (NativeMethods.IsWindow(ctrl.Handle)) { m_WndProcMap[ctrl.Handle] = NativeMethods.GetWindowLongPtr(ctrl.Handle, WindowsLong.GWL_WNDPROC); NativeMethods.SetWindowLongPtr(ctrl.Handle, GWL.GWL_WNDPROC, Marshal.GetFunctionPointerForDelegate(m_CtrlWndProcDelegate)); } if (!ctrl.HasChildren) { return; } foreach (Control child in ctrl.Controls) { HookChildControl(child); } }