A process can set the foreground window only if one of the following conditions is true: The process is the foreground process. The process was started by the foreground process. The process received the last input event. There is no foreground process. The process is being debugged. The foreground process is not a Modern Application or the Start Screen. The foreground is not locked (see LockSetForegroundWindow). The foreground lock time-out has expired (see SPI_GETFOREGROUNDLOCKTIMEOUT in SystemParametersInfo). No menus are active.
A problem occurs if the first instance has a modal MessageBox open, neither I can bring it to the front, not can I change focus to the messagebox. there are the variants I have tried: