Answer the question
In order to leave comments, you need to log in
Why does the window I created on the win32 API break when resizing it?
I think the problem is in this part of the code, but I can't catch it. Tell me please.
By "breaks" I mean that it stops responding to messages and the frame with the cross, collapse-expand and the name disappears
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
SetMapMode(hdc, MM_ISOTROPIC); //логические единицы отображаем, как физические
SetWindowExtEx(hdc, 500, 500, NULL); //Длина осей
SetViewportExtEx(hdc, xView, -yView, NULL); //Определяем облась вывода
SetViewportOrgEx(hdc, xView / 6, yView / 1.1, NULL); //Начало координат
Line(hdc, -10, 0, 100,0);
Line(hdc, 0, -10, 0, 100);
for (int i(0); i < 3; i++)
{
if (points[i][0] != NULL)
{
if (i == 1)
SelectObject(hdc, hPenRed); //Объект делается текущим
else
SelectObject(hdc, hPenWhite); //Объект делается текущим
Line(hdc, points[i][0] - lineSize + 1, points[i][1] - lineSize + 1, points[i][0] + lineSize, points[i][1] + lineSize);
Line(hdc, points[i][0] + lineSize - 1, points[i][1] - lineSize + 1, points[i][0] - lineSize, points[i][1] + lineSize);
}
}
for (int i(1); i < 3; i++)
{
if (points[i][0] != NULL)
{
Line(hdc, points[i-1][0], points[i-1][1], points[i][0], points[i][1]);
}
}
ValidateRect(hWnd, NULL); //Обновляем экран
EndPaint(hWnd, &ps);
break;
case WM_LBUTTONDOWN:
hdc = GetDC(hWnd);
SetMapMode(hdc, MM_ISOTROPIC); //логические единицы отображаем, как физические
SetWindowExtEx(hdc, 500, 500, NULL); //Длина осей
SetViewportExtEx(hdc, xView, -yView, NULL); //Определяем облась вывода
SetViewportOrgEx(hdc, xView / 6, yView / 1.1, NULL); //Начало координат
Line(hdc, 0, 0, 30, 30);
x = LOWORD(lParam); //узнаём координаты
y = HIWORD(lParam);
//Line(hdc, LOWORD(lParam) - LOWORD(lParam), HIWORD(lParam) - HIWORD(lParam), LOWORD(lParam), HIWORD(lParam));
if (check < 3)
{
points[check][0] = x;
points[check][1] = y;
check++;
}
if (check <= 3)
{
if(check == 2)
SelectObject(hdc, hPenRed); //Объект делается текущим
else
SelectObject(hdc, hPenWhite); //Объект делается текущим
Line(hdc, x - lineSize + 1, y - lineSize + 1, x + lineSize, y + lineSize);
Line(hdc, x + lineSize - 1, y - lineSize + 1, x - lineSize, y + lineSize);
}
if (check == 3)
{
Line(hdc, points[0][0], points[0][1], points[1][0], points[1][1]);
Line(hdc, points[1][0], points[1][1], points[2][0], points[2][1]);
}
//закругляемся
//обновляем окно
ValidateRect(hWnd, NULL);
//заканчиваем рисовать
//EndPaint(hWnd, &ps);
break;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question