Print Page | Close Window

Menu shortcuts no longer works

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=12694
Printed Date: 24 September 2024 at 3:15pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Menu shortcuts no longer works
Posted By: BadJerry
Subject: Menu shortcuts no longer works
Date 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



Replies:
Posted By: Oleg
Date Posted: 17 November 2008 at 9:01am
Hi,
not clear how you use CommandBars.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: BadJerry
Date 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


Posted By: MGebler
Date 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 !!!


Posted By: MGebler
Date 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?








Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net