How to set a Wpf Window as the Owner of a Winforms Form

c#, winforms, wpf

Solution

Isn't `SetParent` considered "more correct" than `SetWindowLong` with `GWL_HWDPARENT` (-8)?

[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);

Problem

How to set a System.Windows.Window as the Owner of a System.Windows.Forms.Form? After I searched for this for a while only to realize that I already have the answer in one of my utils classes I decided to put the answer on stackoverflow. Hopefully someone finds this useful.

Original source