May 07
This is one of those things that's obvious once you know it. When dealing with COM, there is often a need to convert a WinForms Form object to an IntPtr handle, and vice versa.
Convert Handle to Form
static public Form GetForm( IntPtr handle ) { return handle == IntPtr.Zero ? null : Control.FromHandle( handle ) as Form; }
Convert Form to Handle
Form form = new Form(); IntPtr handle = form.Handle;
Popularity: 30% [?]
Related posts:
