Answer the question
In order to leave comments, you need to log in
What event is constantly called for a window?
The code needs to be called all the time.
SelectObject(hDC, hPen1); //но в одним момент времени может быть только 1
Rectangle(hDC, 10, 10, 100, 100); //рисуем фигуру соответствующим пером
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hDC;
hDC=GetDC(hWnd);
RECT rect;
static int i;
HPEN hPen1; //объявляем сразу перо
hPen1 = CreatePen(PS_DASH, 1, RGB(0,255, 0)); //создаём
SelectObject(hDC, hPen1); //но в одним момент времени может быть только 1
POINT pt;
switch (message)
{
case WM_PAINT:
GetCursorPos (&pt);
ScreenToClient (hWnd, &pt);
Rectangle(hDC, pt.x, 400, pt.x+100, 450); //рисуем фигуру соответствующим пером
Rectangle(hDC, 0, 0, 100, 50);
Rectangle(hDC, 120, 0, 220, 50);
Rectangle(hDC, 240, 0, 340, 50);
Rectangle(hDC, 360, 0, 460, 50);
Rectangle(hDC, 480, 0, 580, 50);
Rectangle(hDC, 600, 0, 700, 50);
Rectangle(hDC, 720, 0, 820, 50);
Rectangle(hDC, 840, 0, 940, 50);
break;
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_KEYDOWN:
win32_key_down(wParam);
break;
case WM_KEYUP:
win32_key_up(wParam);
SelectObject(hDC, hPen1); //но в одним момент времени может быть только 1
Rectangle(hDC, 10, 10, 100, 100); //рисуем фигуру соответствующим пером
break;
case WM_TIMER:
//hDC = GetDC(hWnd);
//GetClientRect(hWnd,&rect);
//win32_DrawScreen(hDC,&rect);
//ReleaseDC(hWnd,hDC);
//Sleep(10);
break;
case WM_CREATE:
AllocConsole();
//SetTimer(hWnd,12345,20,NULL);
break;
case WM_DESTROY:
main_End();
KillTimer(hWnd,12345);
FreeConsole();
PostQuitMessage(0);
exit(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
hDC = BeginPaint(hWnd, &ps);
Answer the question
In order to leave comments, you need to log in
Throw in the window drawing event + at the end of the event, mark the window as requiring redrawing (SetDirty like)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question