Pressing Arrow Key
-
How do I check to see if the key being pressed is the up, down, left or right arrow key? i.e. to check if "I" is pressed, I do this: void CChildFrame::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { // TODO: Add your message handler code here and/or call default CMDIChildWnd::OnKeyDown(nChar, nRepCnt, nFlags); char keypressed = char(nChar); if(keypressed == 'I') //Do stuff } but what do I write in the if statement to check for an arrow key?
-
How do I check to see if the key being pressed is the up, down, left or right arrow key? i.e. to check if "I" is pressed, I do this: void CChildFrame::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { // TODO: Add your message handler code here and/or call default CMDIChildWnd::OnKeyDown(nChar, nRepCnt, nFlags); char keypressed = char(nChar); if(keypressed == 'I') //Do stuff } but what do I write in the if statement to check for an arrow key?
You can use VK_LEFT, VK_UP, VK_RIGHT and VK_DOWN Nish
The rumours that I am an AI bot are absolutely false. These rumours have been propogated by *them* to focus all the attention on to me, while *their* bots take over the planet. Thank y%%%% Divide by zero. Cannot proceed. Abort(y/y)?
-
How do I check to see if the key being pressed is the up, down, left or right arrow key? i.e. to check if "I" is pressed, I do this: void CChildFrame::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { // TODO: Add your message handler code here and/or call default CMDIChildWnd::OnKeyDown(nChar, nRepCnt, nFlags); char keypressed = char(nChar); if(keypressed == 'I') //Do stuff } but what do I write in the if statement to check for an arrow key?
You can find all of the other lookup codes in MSDN by looking up Virtual Key Codes.
Build a man a fire, and he will be warm for a day
Light a man on fire, and he will be warm for the rest of his life! -
How do I check to see if the key being pressed is the up, down, left or right arrow key? i.e. to check if "I" is pressed, I do this: void CChildFrame::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { // TODO: Add your message handler code here and/or call default CMDIChildWnd::OnKeyDown(nChar, nRepCnt, nFlags); char keypressed = char(nChar); if(keypressed == 'I') //Do stuff } but what do I write in the if statement to check for an arrow key?
You may need to handle the arrow keys in the PreTranslateMessage function which you can override.
if (pMsg->message == WM_KEYDOWN)
{
switch (pMsg->wParam)
{
case VK_UP :
case VK_DOWN :
case ...
}
}you should return TRUE if you dont want te message to be processed further, or pass the message through to the base class to allow it to be processed by controls as normal. Roger Allen Sonork 100.10016 yet to be identified being from the planet Paltinmoriumbanfrettybooter