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


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.


  • Nenad Stefanovic

    • assigned_to: nobody --> nenadstefanovic
  • Nenad Stefanovic

    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

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks