Search code examples
winapimenucreatewindow

Is it possible to create a sub window which will not deactivate the parent?


Normally when creating a sub window (WS_POPUP), the child window will become activate and the parent will become deactivated. However, with menus, both remain active. At least I am assuming the menu is active, it at least has focus.

Example: Click on the file menu in notepad, the menu appears, yet the notepad window still looks active.

Is it possible to mirror this behavior with either a window style or responding to a particular message?

Thanks

Another example: Combo boxes seem to show a subwindow, yet do not deactivate the window. And you can click on that subwindow, while still maintaining an activate main window. Any ideas on how to grab the class /style of that window?


Solution

  • The list dropdown in a combobox is a bit of a hack, it is both a popup and a child window, I can't recommend that approach (Undocumented style combination, and IIRC, it is a bit buggy to do this with a "normal" floating window/toolbar)

    This leaves you with two options:

    • WS_EX_NOACTIVATE (Main window will stay active, floating window is not active)
    • Handle activate messages (Both windows will look active)