I've developed an application that starts external processes (e.g. like the notepad etc.) and displays the main window of the process inside a panel in my application. (Like described in this thread)
The problem is that I get a lot of focus problems with that. E.g. when a window is over my application's window and I click on the window of the sub process, the main window does not come to the foreground.
I've tried to solve this problem by calling SetForegroundWindow from the main application when the child process receives focus, but as this and this thread describes this only works if the process is being debugged or if it is the foreground process. There is a workaround by calling AttachThreadInput, but that doesn't work 100% reliable.
SetForegroundWindow should also work if "The process was started by the foreground process", but in my case it is the other way arround. (The foreground process was started by the process)
Is there a way to get the right to set the foreground window if the focussed window is a child process of my process?