Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Menu shortcuts no longer works
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Menu shortcuts no longer works

 Post Reply Post Reply
Author
Message
BadJerry View Drop Down
Newbie
Newbie


Joined: 22 July 2005
Location: United Kingdom
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote BadJerry Quote  Post ReplyReply Direct Link To This Post Topic: Menu shortcuts no longer works
    Posted: 17 November 2008 at 7:25am
Since installing the commandbars menu, Alt+F does not open the file menu in child dialog-boxes of a view... it works on the view itself...
All the keyboard accelerators are lost as well...
What can I do to make this work on all my dialog-boxes - ideally without too much work...
Thanks in advance,
Jerome
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 17 November 2008 at 9:01am
Hi,
not clear how you use CommandBars.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
BadJerry View Drop Down
Newbie
Newbie


Joined: 22 July 2005
Location: United Kingdom
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote BadJerry Quote  Post ReplyReply Direct Link To This Post Posted: 17 November 2008 at 10:12am
I have a SDI and a MDI application... they both have (CFormView derived ) views which use CDialog derived child windows to display information.  It's within these windows that the shortcuts don't work anymore.
The mainframe window is derived from CXTPMDIFrameWnd.
My dev environment is VC++ 6.0 SP6.
Is there anything else you need?
 
Jerome
Back to Top
MGebler View Drop Down
Groupie
Groupie


Joined: 18 May 2006
Location: Germany
Status: Offline
Points: 64
Post Options Post Options   Thanks (0) Thanks(0)   Quote MGebler Quote  Post ReplyReply Direct Link To This Post Posted: 07 December 2008 at 4:14pm
Similiar constellation - same problem...

I took a look at the grep sample (Samples\Utilities\Grep) and I think that the problem can also been seen there:

1.  Add a new accelerator ( ID_APP_EXIT = 'Alt+Q' )
2.  Compile and start the application
3.  Click into the 'Find what' combo box so that it gets the input focus.
4a. Press 'Alt+F4' and the application quits
4b. Press 'Alt+Q' and nothing happens

Help !!!
Back to Top
MGebler View Drop Down
Groupie
Groupie


Joined: 18 May 2006
Location: Germany
Status: Offline
Points: 64
Post Options Post Options   Thanks (0) Thanks(0)   Quote MGebler Quote  Post ReplyReply Direct Link To This Post Posted: 08 December 2008 at 3:58am
I found a solution.

1st step - Add the following method to the owner of the command bar:

BOOL BoostAccelerator( MSG* pMsg )
{
  if( GetCommandBars() && GetCommandBars()->GetShortcutManager() )
    return GetCommandBars()->GetShortcutManager()->TranslateAccelerator( pMsg );

  return FALSE;
}

2nd step - Override the PreTranslateMessage method of the child dialog:

virtual BOOL PreTranslateMessage(MSG* pMsg)
{
  if( WM_KEYFIRST <= pMsg->message && pMsg->message <= WM_KEYLAST )
  {
    CMainFrame* pMainFrame = ((CMainFrame*)AfxGetMainWnd());
    if( pMainFrame && pMainFrame->BoostAccelerator( pMsg ) )
      return TRUE;
  }

  return __super::PreTranslateMessage(pMsg);
}

The reason for this approach is that
'Accelerators are not an automatic thing for dialogs' (http://msdn.microsoft.com/de-de/magazine/cc301409(en-us).aspx).

And now letīs have a look to the codejock grep sample - if I replace the CSearchOptionsView::PreTranslateMessage implementation with the BoostAccelerator version everything works in the right way.

So dear codejock team - which is the right approach to handle accelerators in child dialogs?





Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.