Solved

How Do I use the WM_CHAR , WM_KEYDOWN , WM_KEYUP

Posted on 2001-07-26
8
1,894 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
8 Comments
 
LVL 12

Accepted Solution

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

Assisted Solution

by:Zoppo
Zoppo earned 25 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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how do i create updater to My Activex application? 3 88
deburging in oracle form 12 99
if loop in java 3 142
wait notify demo infinite loop 3 110
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
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.

777 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