How to add keyboard shortcuts to Menu in an SDI application?
Some of the things that i have tried is :
say Context menu has a sub menu called Menu1 , i have
mentioned it as &Menu1 which makes Ctrl + M as keyboard short
cut for it [ but this apporach is not working ] , Second thing which
i would not like to do is capture the key board event and then call
appropriate method. Any other solution?

Member Avatar for jencas

say Context menu has a sub menu called Menu1 , i have
mentioned it as &Menu1 which makes Ctrl + M as keyboard short
cut for it

No, the '&' does not make Ctrl+M as your keyboard short cut. I think what you are looking for is an "accelerator key".

Hi Jencas, Can u explain me wat is accelerator key?
or can u provide me with any link which explains the same.
i just want to have a keyboard short cut for Menu1 ( the keyboard
short cut would preffered to be Ctrl+M) do we have any alternative solution
other than capturing the keypress event?

Thanks for replying :)

Hi Jencas,

i found out the solution :)

IDR_MAINFRAME ACCELERATORS
BEGIN
"P", ID_CREATE_PATIENT, VIRTKEY, CONTROL
"S", ID_CREATE_STUDY, VIRTKEY, CONTROL
"E", ID_CREATE_EXAM, VIRTKEY, CONTROL
"Z", ID_EDIT_UNDO, VIRTKEY, CONTROL
"X", ID_EDIT_CUT, VIRTKEY, CONTROL
"C", ID_EDIT_COPY, VIRTKEY, CONTROL
"V", ID_EDIT_PASTE, VIRTKEY, CONTROL
VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT
VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT
VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL
VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT
VK_F6, ID_NEXT_PANE, VIRTKEY
VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT
END

Just go to the resource.rc file right click -> view code,
then add the code , simple :)
thank's a lot

OH GOD.....
One more thing !
i have added the keyboard short cut for Menu1 say ctrl + M,
but how to add short cut like this :
Menu1 :: Alt + M + N..... i have tried adding the ascii and many different stuff
any one reply plz

Member Avatar for jencas

You can configure something like Strg + Alt + M as keyboard short cut in the resource file but you can't use combinations with two characters

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.