Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


#30 CommandBar: don't steal focus on menu activation

Alexander Savin

When MDI menu is activated by pressing Alt-key or via
mouse click, the command bar steals the focus from the
currently active pane/bar or child frame. Although
CBR_EX_ALTFOCUSMODE flag allows restoring the focus
to the previous state and TakeFocus/GiveFocusBack can
be overridden, it is not exactly what could be needed.

For example, I may want to alter the menu items
depending on where the focus resides (pane or child
frame), or to dispatch a command message to the focus
window (not necessarily a child frame). Also, if I have a
caption of docked pane drawn in active or inactive color
depending on the focus, the caption becomes inactive
when menu is activated and it is not obvious where the
command will be routed.

Instead of capturing the focus, a keyboard hook could
redirect inputs from active window to the command bar.
This would simulate the behavior of standard menu.

Thanks a lot.


  • Logged In: YES

    Hi Alexander,

    You are correct - a menu, which command bar emulates,
    should not take focus. However, the current state of the
    command bar code is rather fragile, and it is unlikely that we
    will be able to change this behavior without rewriting major
    portions of the code. Because of that, this is not a simple fix
    and will not happen soon.




Cancel   Add attachments