Yes, AliR. What you said is the method of adding shortcut. But after
run, and after you release F10 key, the focus will be set on menu bar.
Seetharam is right. I have to catch WM_SYSKEYUP+VK_F10 in
PreTranslateMessage. And this will not affect the ID_MYF10 command
Do not try to catch the F10 key in OnKeyDown, or in PreTranslateMessage.
Do it the right way, it will only take 2 minutes to do.
Open your resource editor, open the accelerator table (IDR_MAINFRAME).
First make sure there is no item that is assigned F10, then go to the
bottom of the list and insert a new item, give it an ID (for example
ID_MYOPERATION, this can be the same as a menu item id, if you do that
then when the short cut key is pressed, then it will be like the user
selected the menu item), and select F10 as the key, make sure the
Modifier is either blank or says None.
Then go to your class where you want to handle the F10 key, and handle
the ID of the accelerator just like you would a menu item.
Now F10 no longer does its default thing, and does whatever you want to
"fiveight" <firstname.lastname@example.org> wrote in message
In explorer, if I press F10, the focus will be set on menu bar. But in
vs2008, F10 is the shortcut of "next" command. In my own MFC program, I
use F10 as a shortcut of a command too. When press F10, the command will
run first, and then the focus will be set on menu bar. How can I use F10
to run the command and not change the focus? I try to catch
WM_KEYUP+VK_F10 message in PreTranslateMsg function of CWinApp, But it
does not work.