?
Solved

How Do I use the WM_CHAR , WM_KEYDOWN , WM_KEYUP

Posted on 2001-07-26
8
Medium Priority
?
1,925 Views
Last Modified: 2013-11-20
HOW DO I IMPLEMENT THE WM_CHAR ,WM_KEYDOWN, WM_KEYUP MESSAGES IN MY DIALOG BOX Application

 I tried this out but it did not work why???


Void CASCIIDlg::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default

         MessageBox("hai");
         
     CDialog::OnKeyDown(nChar, nRepCnt, nFlags);
}


The message hai was not printed,when i pressed a key.


 if i want to detect a keypress what should i do

 i tried this but it did not work


void CASCIIDlg::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
      if(nChar == VK_A)
       MessageBox("hai");
         
     CDialog::OnKeyDown(nChar, nRepCnt, nFlags);
}

    by using the code above i am trying to print the  
    message "hai" when the A key is pressed down but it
    not respond me.

    explain me how do i make use of VIRTUAL KEYS.


    give me a small example coding which clearly explaines
    how to implement these windowsmessages.

   I am working in dialog based application.



   
0
Comment
Question by:vsulu
[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
8 Comments
 
LVL 12

Accepted Solution

by:
migel earned 100 total points
ID: 6325749
Hi!
you need to use PreTranslateMessage for that messages
0
 
LVL 31

Assisted Solution

by:Zoppo
Zoppo earned 100 total points
ID: 6325803
>I tried this out but it did not work why???
Because default implementation of CDialog::PreTranslateMessage() calls CWnd::PreTranslateInput() which itself calls CWnd::IsDialogMessage() for key- and mouse-messages. This IsDialogMessage() then dispatches the message so it nevermore reaches your dialog class.

You'll need to override PreTranslateMessage for your dialog class as migel suggested.

ZOPPO


PS: This is only additional info ... give the points to migel.
0
 
LVL 12

Expert Comment

by:migel
ID: 6325839
>>to ZOPPO
your suggestion is more explanative (...hmm sorry my English is not so good).
0
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 
LVL 31

Expert Comment

by:Zoppo
ID: 6325857
to migel:
I believe it's a good habit to not only tell the people 'do this' but to tell them 'do this in that way because ...', because I think so people can faster learn mechanisms used in MFC.

Further I don't think my English is better, but I guess my German is as good as your Russian     ;o)

ZOPPO
0
 
LVL 12

Expert Comment

by:migel
ID: 6326056
to zoppo
>>Completelly agree
0
 
LVL 1

Expert Comment

by:ksenthilraj
ID: 6831036
Listening
0
 
LVL 12

Expert Comment

by:migel
ID: 6831176
Hey!
anybody here??
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 9490570
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered by : Zoppo, migel (points to be split)

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Roshan Davis
EE Cleanup Volunteer
0

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
In this post we will learn different types of Android Layout and some basics of an Android App.
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 this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

770 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