1

I’m currently writing an MFC dialog app which has a menu. The menu displays correctly and the menu entries work correctly via mouse, accelerators, and hotkeys (e.g., to quit: Ctrl+Q or Alt+F,Q).

Unfortunately, the Enter key doesn’t seem to work. That is, pressing Alt+F will open the File menu and pressing will highlight the Quit entry, but pressing Enter will not select it.

I know that using menus in dialog apps can be a bit tricky, but I’ve done this successfully before. However, that was a long time ago with a customized VS wizard, so I am trying to remember how to do this from scratch. I tried checking my old code, but could not find anything in reference to VK_RETURN. (No, there’s nothing special in PreTranslateMessage.)

These two questions are related, but they want the dialog to receive the key, I need the menu to get it.

Does anyone know what the problem is and how to fix it?

Community
  • 1
  • 1
Synetech
  • 9,643
  • 9
  • 64
  • 96
  • Have you tried using Spy++ to see who may be handling the Enter key? Try spying the dialog. – rrirower Jul 25 '14 at 20:22
  • Actually, Spy++ doesn’t seem to work at all. I even tried running it as admin and setting it to watch the Windows Calculator, but it still logs nothing whatsoever. – Synetech Jul 25 '14 at 20:42
  • I made a simple MFC dialog based application with a menu using the VS wizard, hitting `Enter` after highlighting a menu item seems to work ok (even when there's a multiline Edit control with WantReturn that has the focus) -- there must be some code in your application that swallows the enter key... – Edward Clements Jul 26 '14 at 07:00
  • Are you using the correct (eg. 32 vs 64 bit) version of Spy++? – rrirower Jul 27 '14 at 15:17

0 Answers0