Solved

keyboard event

Posted on 1999-01-21
3
215 Views
Last Modified: 2010-04-02
How do i detect a key? eg arrow key from keyboard???
i can use wm_keydown but then how do i detect which key?
thanks.
0
Comment
Question by:at75
[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
3 Comments
 
LVL 3

Accepted Solution

by:
_Scotch_ earned 10 total points
ID: 1184802
Its the wParam that is passed to your handler.  All keys have
their own symbols, VK_RIGHT or VK_LEFT or VK_F17 for example,
that are defined in WINUSER.H
0
 

Author Comment

by:at75
ID: 1184803
Scotch:thanks.i tried that too.but don't seems to work.
the error is :'wParam' : undeclared identifier
this is my code:
void CDhView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{

switch(wParam)
      case VK_RIGHT:
            alpha += 3.0f;
                        if (alpha >= 360.0f)
                alpha=0.0f;
        break;
}

any idea what's goes wrong?
thanks
0
 
LVL 3

Expert Comment

by:_Scotch_
ID: 1184804
When you said "wm_keydown" is misled myself into thinking
that you were in a win32 style message loop.  You're not.  It
looks more like the classwizard generated handler in which case
you want to

switch (nChar)  {
    case VK_RIGHT:
        ...
    case VK_LEFT:
        ...
    case yada-yada-yada
        ...
    default:
        ...
    }

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

630 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