I need to be able to get a WinForm dialog's Owner's HWND. In unmanaged I have a background thread that gets the HWND for the window in front. The code then calls ::GetParent(frontHWND) to see if it needs to hide a different non-modal MFC dialog. When the WinForm dialog is the frontHWND, I always get NULL back for the GetParent call. I have also tried GetOwner realizing .Net tried to cleanup the difference between Parent and Owner. Looking at the WinForm dialog w/ Spy++, it also say the WinForm has no parent or owner. I have passed in
NativeWindow ^natWin = gcnew NativeWindow();
natWin->AssignHandle(IntPtr(hwndParent));
managedDlg->ShowDialog(natWin);
The above code didn't set the owner of the WinForm. I tried calling the Win32 SetParent from the WinForm code in OnFormShown(), but the locked up the MFC application and the WinForm.
Can someone explain how to get my unmanaged dialog/app to be the owner/parent of the managed winform?