所以我一直试图弄清楚以下几点:
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hDC; // Display context handle
PAINTSTRUCT PaintSt; // Structure defining area to be drawn
RECT aRect; // A working rectangle
HPEN hPen; // A working pen
HBRUSH hBrush; // A working brush
switch(message)
{
case WM_TIMER:
switch(wParam)
{
case IDT_TIMER1:
redraw = true;
InvalidateRect(hWnd, NULL, TRUE);
case IDT_TIMER2:
if(keys[UP])
{
rect2.bottom -= 5;
rect2.top -= 5;
}
if(keys[DOWN])
{
rect2.bottom += 5;
rect2.top += 5;
}
if(keys[RIGHT])
{
rect2.left += 5;
rect2.right += 5;
}
if(keys[LEFT])
{
rect2.left -= 5;
rect2.right -= 5;
}
}
return 0;
case WM_PAINT:
//if(redraw)
{
redraw = false;
render_frame();
}
return 0;
case WM_KEYDOWN:
switch(wParam)
{
case VK_UP:
keys[UP] = true;
break;
case VK_DOWN:
keys[DOWN] = true;
break;
case VK_LEFT:
keys[LEFT] = true;
break;
case VK_RIGHT:
keys[RIGHT] = true;
break;
default:
break;
}
return 0;
case WM_KEYUP:
switch(wParam)
{
case VK_UP:
keys[UP] = false;
break;
case VK_DOWN:
keys[DOWN] = false;
break;
case VK_LEFT:
keys[LEFT] = false;
break;
case VK_RIGHT:
keys[RIGHT] = false;
break;
default:
break;
}
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return DefWindowProc(hWnd, message, wParam, lParam); // default message processing
}
}
所以这就是问题所在:在WM_PAINT: 的情况下,当我取消注释 if 语句时,时间由于某种原因停止计时。我不知道为什么,也不知道如何将这与任何事情联系起来。因此,如果我取消注释它,它将不会呈现,也不会从另一个计时器(有两个计时器)接收信息。请帮助我,如果它很傻,请不要笑。