c++ - weird if statement causing to shut timer -


So I'm trying to try the following:

  LRESULT callback window process (hwd ) HWND, UINT Message, Varm Vaporam, LAPRM LPRAM) {HDC HDC; // Display Reference Handle Painting Paint Street; // Defined Area Defined Area; RECT Ract; // A working rectangle HPN Hippin; // A working pen HBRUSH H brush; // A working brush switch (message) {case WM_TIMER: switch (WPAM) {case IDT_TIMER1: redraw = true; Invalid note (hWnd, NULL, TRUE); Case IDT_TIMER2: If (key [UP]) {rect2.bottom - = 5; Rect2.top - = 5; } If (key [down]) {rect2.bottom + = 5; Rect2.top + = 5; } If (key [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 (WPAM) {Case VK_UP: Key [UP] = True; break; Case VK_DOWN: key [bottom] = true; break; Case VK_LEFT: key [left] = true; break; Case VK_RIGHT: key [right] = true; break; Default: Break; } Return 0; Case WM_KEYUP: Switch (WPARM) {Case VK_UP: Key [UP] = Wrong; break; Case VK_DOWN: key [bottom] = false; break; Case VK_LEFT: key [left] = wrong; break; Case VK_RIGHT: key [right] = false; break; Default: Break; } Return 0; Case WM_DESTROY: PostQuitMessage (0); Return 0; Default: Return DefWindowProc (hWnd, message, wParam, lParam); // default message processing}}   

Here's the problem: In case WM_PAINT: , when I cancel the I statement, Sticks. I do not know why and why it is not correlated with anything, so if I deny it, then it will not render, nor will she get information from other timers (there are two timers). Please help me, and if it is stupid, do not laugh.

WM_TIMER message is a "low priority" message, it is only generated when there is a need to do anything The problem with your WM_PAINT handler is that it is generated first time when it is generated immediately after creating the window. Endpaint () is not called, which turns on the "window dirty" position bit. Which instantly causes another WM_PAINT message to be generated, which will not still paint because redraw is not true. Etc., your app is burning 100% of the core on WM_PAINT messages and never enough becomes inactive to generate WM_TIMER messages.

To fix your problem simply remove the redraw test. Always attract it when Windows asks for it. Or pass the message to DefWindowProc ().

Comments