How to change a Window Owner using its handle

I think you're looking for is to P/Invoke SetWindowLongPtr(win32window, GWLP_HWNDPARENT, formhandle)

Google Search


Yes! I've already have a P/Invoke import of SetWindowLongPtr (which is x64 safe). And using Reflector I searched upon the Form.Owner property ( i.e. the get_Owner(Form value) method ) and managed to change the owner with

SetWindowLongPtr(childHdl, -8, OwnerHdl)

I was looking what the -8 (0xFFFFFFFFFFFFFFF8) meant before I could post the solution here, but Joel has already pointed it out.

Thanks!