I have a MFC app that posts a message through a COM interface to open a form on another process both in C++. That process in turn is using an ActiveX control to pass the message on to open either a WinForm or WPF window (.NET). I am passing over the HWND of my original MFC dialog in order to have the new dialog become a child.
Everything up to this point is working, though the WPF form required me to disable the parent in addition to setting the owner via a WindowInteropHelper and of course re-enable the parent on closing.
The problem I'm having occurs when I close the form. When I close the WinForm, the original dialog becomes active, but when I close the WPF form any window that had focus at any point earlier becomes active. The only way I can reactivate my MFC dialog is by clicking on the title bar.
I have tried a dozen ways of trying to call SetForegroundWindow and checked to make sure that my process is the current active process. If I put a break point in and continue, then my main dialog becomes active properly.