Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

keyboard event

Posted on 1999-01-21
3
Medium Priority
?
217 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
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
_Scotch_ earned 20 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

824 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