Solved

keyboard event

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

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

Suggested Solutions

Title # Comments Views Activity
Should CArray be used for a list of pointers in C++? 19 128
White board coding practice 3 93
c++, dynamic object by json 1 60
Error creating a new C++ project in ,net 20 51
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

762 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