views:

222

answers:

1

I'm trying to debug a huge Win32 GUI application (I have full sources) divided into several processes. The problem is the following: in one process I have a dialog with a listbox, when I double-click an item in the listbox another process is started that creates its own window that is brought to front and covers the initial dialog. If I do some manipulations (that I can't fully explain yet since I don't fully understand them yet) something forces the initial dialog to start flashing in the taskbar.

I tried Microsoft Spy++ and see that whenever I do that manipulation WM_ACTIVATE is sent to the dialog, most of the times it has these parameters:

fActive: WA_INACTIVE fMinimized:False hwndPrevious:(null)

and in those cases the dialog doesn't starts flashing. But once in a while the parameters are

fActive: WA_ACTIVE fMinimized:False hwndPrevious:(null)

and that precisely corresponds to the dialog flashing.

MSDN says WM_ACTIVATE is sent with WA_ACTIVE when a window is activated by some method other than a mouse click (for example, by a call to the SetActiveWindow function or by use of the keyboard interface to select the window).

Now in the application code SetActiveWindow() is never called and I don't do anything with the keyboard that could switch windows.

What other reasons are possible for WM_ACTIVATE being sent with WA_ACTIVE?

A: 

If you create a window with WS_VISIBLE style, the window will be activated on creation.

If you do a ShowWindow(SW_SHOW) it will activate the window (Use SW_SHOWNA instead)

If you do a SetWindowPos without the SWP_NOACTIVATE flag, the window will be activated.

Finaly, if you create a window with a template (CDialog), the window is always activated.

Hyksos
A little note on what I said, in case of the dialog, you can prevent it from getting activated, you need to return FALSE in your OnInitDialog and the dialog have to be created modeless without WS_VISIBLE style and you show it with ShowWindow(SW_SHOWNA)
Hyksos