I have a EXE implemented as a MFC CPropertySheet (for diagnostic interface) that acts as a server process to a main application. The main application launches it on startup, and I want the server to be initially invisible and background.
I am using CreateProcess (have also tried WinExec) and while the process does launch hidden, it always steals the activation (ie. deactivates the main application) when it launches, even when invisible.
I have tried so many things to stop this happening:
- Setting the STARTUPINFO parameters
- Overriding OnWindowPosChanging with SWP_NOACTIVATE in the server
- Creating the CPropertySheet as modeless with Create instead of DoModal
It doesn't happen with a CDialog based process that I grafted in as a test, so it seems to be an issue only with the CPropertySheet or the underlying Windows common control that implements it.
Does anyone have any ideas why this is happening? Or any tips on trying to diagnose where the activation is occurring? I'm really stumped.