I've been thinking about this problem for some time now and read on msdn and in some books but i wonder how to get the WM_KEYDOWN to respond instantly while holding for example the "UP"-key?
right now its a little paus before the repeats start!
i know that maybe you could use GetAsyncKey(); in the main-loop in the WinMain function(?) but i would like to get some help on how to implement this feature in the WndProc message-handler!
here's my code this far:
rcFill is just a filled rect that moves when keybuttons are pressed :)
thanks in advance.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 | switch(message)
{
case WM_KEYDOWN:
{
if(WParam == VK_UP)
{
LParam = ( 1 << 30);
rcFill.top -= vel;
rcFill.bottom -= vel;
InvalidateRect(hwnd, 0, true);
}
if(WParam == VK_DOWN)
{
rcFill.top += vel;
rcFill.bottom += vel;
InvalidateRect(hwnd, 0, true);
}
if(WParam == VK_RIGHT)
{
rcFill.right += vel;
rcFill.left +=vel;
InvalidateRect(hwnd, 0, true);
}
if(WParam == VK_LEFT)
{
rcFill.right -= vel;
rcFill.left -=vel;
InvalidateRect(hwnd, 0, true);
}
} break;
|