Search code examples
.netvb.netwinformshandleintptr

Need IntPtr for a Form (VB.Net)


I need the intPtr for a form. Control.FromHandle(control) gives me the control from a handle, but I need the opposite--get the handle from a control. How do I do this?


Solution

  • Try

    Dim handle As IntPtr = someControl.Handle
    

    Note: This will only work after the Handle for the control is created. There is a window of time in between when you create a control and when it is rendered to some degree where this may return IntPtr.Zero