T Thomas Jul 10, 2003 #1 How do I go about getting the handle of a windows form control in C# so that I can use it in a PInvoke call to SendMessage?
How do I go about getting the handle of a windows form control in C# so that I can use it in a PInvoke call to SendMessage?
M Mark Erikson Jul 14, 2003 #2 Thomas said: How do I go about getting the handle of a windows form control in C# so that I can use it in a PInvoke call to SendMessage? Click to expand... Very simple. using System.Runtime.InteropServices; [DllImport("coredll")] public static extern IntPtr GetFocus(); public IntPtr GetHandle(Control c) { c.Focus(); IntPtr hWnd = GetFocus(); return hWnd; } Mark Erikson
Thomas said: How do I go about getting the handle of a windows form control in C# so that I can use it in a PInvoke call to SendMessage? Click to expand... Very simple. using System.Runtime.InteropServices; [DllImport("coredll")] public static extern IntPtr GetFocus(); public IntPtr GetHandle(Control c) { c.Focus(); IntPtr hWnd = GetFocus(); return hWnd; } Mark Erikson