Re: Menu Not Available from Keyboard
From: Joseph M. Newcomer (newcomer_at_flounder.com)
Date: 12/31/04
- Next message: San: "Convert from GUID to String and vice versa"
- Previous message: Joseph M. Newcomer: "Re: how to display full path instead of filename"
- Next in thread: Frank Hickman [MVP]: "Re: Menu Not Available from Keyboard"
- Reply: Frank Hickman [MVP]: "Re: Menu Not Available from Keyboard"
- Maybe reply: Jonathan Wood: "Re: Menu Not Available from Keyboard"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 31 Dec 2004 16:27:53 -0500
Yes, this is one of hte problems with dialog-based apps. There is also an MSDN article on
how to use keyboard menu shortcuts, but I can't find it in the latest MSDN (while they
still retain Win16 articles, many of the useful other articles seem to get purged. There
is a trick you have to do to make the shortcut keys work. But I spent a fair amount of
time doing MSDN searches and couldn't locate it. And I know I've seen it there.
joe
On Thu, 30 Dec 2004 09:01:54 -0800, "Tom Serface" <tserface@msn.com> wrote:
>UPDATE_COMMAND_UI stuff doesn't work well for menus in a dialog. I have
>this problem with context (right click) menus and I've fixed it by
>implementing a handler for:
>
>ON_WM_INITMENUPOPUP()
>
>That looks like this:
>
>void CMyDialog::OnInitMenuPopup(CMenu* pMenu, UINT nIndex, BOOL bSysMenu)
>{
> if (bSysMenu)
> return; // don't support system menu
>
> ASSERT(pMenu != NULL);
>
> // check the enabled state of various menu items
> CCmdUI state;
> state.m_pMenu = pMenu;
> ASSERT(state.m_pOther == NULL);
> ASSERT(state.m_pParentMenu == NULL);
> state.m_pParentMenu = pMenu; // parent == child for tracking popup
> state.m_nIndexMax = pMenu->GetMenuItemCount();
> for (state.m_nIndex = 0; state.m_nIndex < state.m_nIndexMax;
>state.m_nIndex++) {
> state.m_nID = pMenu->GetMenuItemID(state.m_nIndex);
> if (state.m_nID == 0)
> continue; // menu separator or invalid cmd - ignore it
> ASSERT(state.m_pOther == NULL);
> ASSERT(state.m_pMenu != NULL);
> state.m_pSubMenu = NULL;
> state.DoUpdate(this, false);
> }
>}
>
>This pumps the messages to the correct handlers right before the menu is
>popped up. I assume something like this would work for other kinds of menus
>in a dialog rather than just context menus.
>
>Tom
>
>"Frank Hickman [MVP]" <fhickman_NOSP@M_noblesoft.com> wrote in message
>news:ltLAd.56$Km.47@fe04.lga...
>> This is probably due to the handlers not being in available when your
>> other windows have the focus. You can do a few things to work around
>> this...write handlers for all the dialogs which call common code, write
>> UPDATE_COMMAND_UI handlers for the functions that keep them enabled but I
>> think they would still need some kind of link to the command code, or move
>> all the command code to the main frame window in which case the
>> functionality would always be available so you would probably need
>> UPDATE_COMMAND_UI handlers to disable functionality that is not available.
>> For instance, you would not want the save functionality if no document was
>> open.
>>
>> --
>> ============
>> Frank Hickman
>> Microsoft MVP
>> NobleSoft, Inc.
>> ============
>> Replace the _nosp@m_ with @ to reply.
>>
>>
>> "Jonathan Wood" <jwood@softcircuits.com> wrote in message
>> news:u6Ts8ng7EHA.2552@TK2MSFTNGP09.phx.gbl...
>>>I have a modeless dialog box (contained in some dockable windows in an MDI
>>> app).
>>>
>>> Mostly, it's working okay but when a control in the dialog box has the
>>> focus, the main window menu is unavailable by keyboard (Alt+F, etc. have
>>> no
>>> effect).
>>>
>>> I've modelled my code after some other applications and notice the menus
>>> in
>>> these applications work even when the dialogs have the focus. Does anyone
>>> have any suggestions on where I'd look to determine how to keep my menus
>>> working?
>>>
>>> Thanks!
>>>
>>> --
>>> Jonathan Wood
>>> SoftCircuits
>>> http://www.softcircuits.com
>>> Available for consulting: http://www.softcircuits.com/jwood/resume.htm
>>>
>>>
>>
>>
>
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
- Next message: San: "Convert from GUID to String and vice versa"
- Previous message: Joseph M. Newcomer: "Re: how to display full path instead of filename"
- Next in thread: Frank Hickman [MVP]: "Re: Menu Not Available from Keyboard"
- Reply: Frank Hickman [MVP]: "Re: Menu Not Available from Keyboard"
- Maybe reply: Jonathan Wood: "Re: Menu Not Available from Keyboard"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|