Re: Using accelerators in a dialog menu
call TranslateAccelerator in PreTranslateMessage
see http://msdn.microsoft.com/en-us/library/cc301409.aspx
--
Sheng Jiang
Microsoft MVP in VC++
"Les" <l.neilson@nospam.acecad.co.uk> wrote in message
news:fvsjdo$brj$1@newsreader.cw.net...
In a MFC dll I have a simple dialog consisting only of a multiline rich
edit
box and a menu.
One of the dropdown menu choices is to Search the contents of the edit box
with Find, Next and Previous options.
All is working fine but then I thought I would like to add function key
accelerators for next (F3) and previous (Shift+F3) as shown below. But
pressing F3 or Shift+F3 nothing happens and Spy++ shows no messages are
being sent to the dialog when the keys are pressed.
We have another small application which uses similar accelerators without
any problem but that is on a mainframe window not a dialog.
Any ideas if I have missed something ?
In the "rc" resource file : (the literal strings are replaced by language
specific strings)
The menu is :
IDR_PADVIEW MENU
BEGIN
<snip>
POPUP "Search"
BEGIN
MENUITEM "Find", IDC_FIND
MENUITEM "Next", IDC_NEXT
MENUITEM "Previous", IDC_PREVIOUS
END
<snip>
END
The accelerator definition :
IDR_PADVIEW ACCELERATORS
BEGIN
VK_F3, IDC_NEXT, VIRTKEY, NOINVERT
VK_F3, IDC_PREVIOUS, SHIFT, VIRTKEY, NOINVERT
END
The dialog definition has a "MENU IDR_PADVIEW" entry
The cpp file has :
BEGIN_MESSAGE_MAP(CPadView, CDialog)
//{{AFX_MSG_MAP(CPadView)
<snip>
ON_COMMAND(IDC_FIND, OnFind)
ON_COMMAND(IDC_NEXT, OnNext)
ON_COMMAND(IDC_PREVIOUS, OnPrevious)
<snip>
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
Thanks for any suggestions
Les