Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


sensing WM_KEYDOWN in modeless dialog

Posted on 1999-10-11
Medium Priority
Last Modified: 2013-11-20
I have a modeless dialog with several controls in it (buttons, listbox, edit box).  Whenever the dialog box is selected, I want to be able to hit an accelerator key and have it pop up another dialog box.  I tried handling WM_KEYDOWN in the dialog box itself, and it didn't work--the messages are going to one of the controls (depending on which one has the focus).  Do I need to make each of the controls able to handle the WM_KEYDOWN message, or is there an easier way?  TIA for the help!
Question by:danbind
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Author Comment

ID: 2117514
Edited text of question.
LVL 23

Accepted Solution

naveenkohli earned 400 total points
ID: 2117565
Do it in PreTranslateMessage function. If you want to handle the message, return FALSE after preocessing. Otherwise let it go to next window..

BOOL CAdderDialog::PreTranslateMessage(MSG* pMsg)
      if (pMsg->message == WM_KEYDOWN) {
            TRACE0 (_T ("Key down\n"));
      return CDialog::PreTranslateMessage(pMsg);

Author Comment

ID: 2120030
Bingo!  This works, and makes sense.  Thanks a lot.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question