• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 861
  • Last Modified:

How to assign accelerator key to IDR_MAINFRMAE_256 Toolbar ?

I  have developed  MDI application  using VC++ 2010 professional.
It  uses IDR_MAINFRAME_256 toolbar.I have removed all standard buttons and added my own buttons.Now  I want to give shortcut key to it, so I modified accelerator
resource  (already existing resource named  IDR_MAINFRAME) added  Toolbar button ID and  shortcut key,but it didnot worked. So I  added another accelerator resource and named it as IDR_MAINFRAME_256 and added ID and  key but still it did not work .
Will you please tell me how to assign shortcut key
0
ADITYA RAO
Asked:
ADITYA RAO
  • 3
  • 3
  • 3
3 Solutions
 
AndyAinscowCommented:
You need to have a menu item with that ID - then you should be able to assign the accelerator key to it.
0
 
ADITYA RAOAuthor Commented:
Sorry It does not work even if we have Menu item or subitem by that same ID ?
0
 
AndyAinscowCommented:
Oh - maybe I mixed it up with another problem that was cured by that.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
sarabandeCommented:
the accelerators don't work for modal dialogs cause those have a seperate message loop which doesn't translate the mainframe accelerator keys.

to use customized short-cuts in a dialog, override the PreTranslateMessage function for your dialog (or your baseclass for dialogs) and call global function TranslateAccelerator.

see http://support.microsoft.com/kb/222829/en-us for details.

Sara
0
 
ADITYA RAOAuthor Commented:
Actually I  have MDI application who has five CFormView derived classes,which open by
click of five Toolbar buttons (each one) for that toolbar I  have to assign shortcut keys
0
 
sarabandeCommented:
formviews were not modal. hence, they would use accelerator resource of IDR_MAINFRAME which is id of the mainframe or (likely) additional accelerator which has same id as their corresponding frame window (document type).

so probably your accelerator resource simply has wrong id.

nevertheless you may get your naming work by overriding PreTranslateMessage same way as it was described for modal dialogs.

Sara
0
 
sarabandeCommented:
the toolbar is associated to frame window (class CMDIChildWnd). so i think you need to override the PreTranslateMsg of your frame classes derived from CMDIChildWnd.

Sara
0
 
AndyAinscowCommented:
VS 2010, MDI project:
Accelerators do work here.  Put another way ctrl + A I can link up (direct from the resource editor - accelerator table).
Maybe you need to say more about what keypress you are trying to use as the accelerator.
0
 
ADITYA RAOAuthor Commented:
Yah it worked perfectly well when I  added code for PreTranslateMessage
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 3
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now