Solved

keyboard event

Posted on 1999-01-21
3
209 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 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
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.

705 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now