Whether 'Control' Key is pressed ?
-
I response the WM_KEYDOWND message to shift my view if the arrow keys are pressed, while the moving speed should be faster if Control key is pressed simultaneously. This line of code is used:
case VK_LEFT:
case VK_RIGHT:
if (GetKeyState(VK_CONTROL) == -128 || GetKeyState(VK_CONTROL) == -127)
{
// Do somthing here.
}I do think there should exist a better way than this stupid one, do you know that?
-
I response the WM_KEYDOWND message to shift my view if the arrow keys are pressed, while the moving speed should be faster if Control key is pressed simultaneously. This line of code is used:
case VK_LEFT:
case VK_RIGHT:
if (GetKeyState(VK_CONTROL) == -128 || GetKeyState(VK_CONTROL) == -127)
{
// Do somthing here.
}I do think there should exist a better way than this stupid one, do you know that?
I think the code can't work.Unlike "shift" key,you can't catch the "control" key in the WM_KEYDOWN.You should handle it in PreTranslateMessage(). //Do the Ctrl+A action BOOL C***::PreTranslateMessage(MSG* pMsg) { if( pMsg->message == WM_KEYDOWN ) { int vkey = pMsg->wParam; if( vkey == 'A' ) { if( GetKeyState( VK_CONTROL ) & 0x8000 ) SelectAll(); } } return CBase***::PreTranslateMessage( pMsg ); } Chreers
-
I response the WM_KEYDOWND message to shift my view if the arrow keys are pressed, while the moving speed should be faster if Control key is pressed simultaneously. This line of code is used:
case VK_LEFT:
case VK_RIGHT:
if (GetKeyState(VK_CONTROL) == -128 || GetKeyState(VK_CONTROL) == -127)
{
// Do somthing here.
}I do think there should exist a better way than this stupid one, do you know that?
Use
GetAsyncKeyState
instead... Mustafa Demirhan http://www.macroangel.com Sonork ID 100.9935:zoltrix