Solved

Help with WM_KEYDOWN

Posted on 1997-11-08
2
399 Views
Last Modified: 2013-11-20
Help,
I Can't Get the WM_KEYDOWN handler, using OnKeyDown to work in a dialog base application.

The program never runs OnKeyDown, when a key is pressed.
 
Eric
0
Comment
Question by:Erics
[X]
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 Comments
 
LVL 7

Accepted Solution

by:
galkin earned 50 total points
ID: 1309630
You cannot handle WM_KEYDOWN message in Dialog based applications. Istaed, overwrite your CDialog derived class' PreTranslateMessage function and check whether message filad of pMsg structure is WM_KEYDOWN
BOOL CYourDialog::PreTranslateMessage( MSG* pMsg )
{
if(pMsg->message == WM_KEYDOWN)
{
 // do whatever you want
return TRUE; // important!!!, do not call base class             //implementation in this case
}

return CDialog::PreTranslateMessage( pMsg );

}

0
 

Author Comment

by:Erics
ID: 1309631
Thanks
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

761 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