Solved

keyboard event

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Suggested Solutions

Title # Comments Views Activity
C++ assignment question 7 236
Which IDE to use to begin C++ training? 5 65
How to convert MFC::CString to UTF8 wchar_t* 10 276
Dialogbox API leak? 18 98
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
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 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…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

791 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