Skip to content

Commit

Permalink
Remove WM_PAINT handler
Browse files Browse the repository at this point in the history
  • Loading branch information
eschan145 committed Jan 21, 2025
1 parent 8ea492c commit 7874b2e
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions src/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,38 +618,38 @@ LRESULT CALLBACK Application::WindowProc(
break;
}

case WM_PAINT: {
RECT rect;
GetClientRect(app->hwnd, &rect);
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;

PAINTSTRUCT ps;
HDC hdc = BeginPaint(app->hwnd, &ps);
HDC buffer = CreateCompatibleDC(hdc);
HBITMAP bitmap = CreateCompatibleBitmap(hdc, width, height);
HBITMAP old_bitmap = (HBITMAP)SelectObject(buffer, bitmap);

for (const auto& widget : app->widgets) {
SendMessage(
widget,
WM_PRINT,
(WPARAM)buffer,
PRF_CLIENT |
PRF_CHILDREN |
PRF_NONCLIENT
);
}

BitBlt(hdc, 0, 0, width, height, buffer, 0, 0, SRCCOPY);

SelectObject(buffer, old_bitmap);
DeleteObject(bitmap);
DeleteDC(buffer);
EndPaint(app->hwnd, &ps);

break;
}
// case WM_PAINT: {
// RECT rect;
// GetClientRect(app->hwnd, &rect);
// int width = rect.right - rect.left;
// int height = rect.bottom - rect.top;

// PAINTSTRUCT ps;
// HDC hdc = BeginPaint(app->hwnd, &ps);
// HDC buffer = CreateCompatibleDC(hdc);
// HBITMAP bitmap = CreateCompatibleBitmap(hdc, width, height);
// HBITMAP old_bitmap = (HBITMAP)SelectObject(buffer, bitmap);

// for (const auto& widget : app->widgets) {
// SendMessage(
// widget,
// WM_PRINT,
// (WPARAM)buffer,
// PRF_CLIENT |
// PRF_CHILDREN |
// PRF_NONCLIENT
// );
// }

// BitBlt(hdc, 0, 0, width, height, buffer, 0, 0, SRCCOPY);

// SelectObject(buffer, old_bitmap);
// DeleteObject(bitmap);
// DeleteDC(buffer);
// EndPaint(app->hwnd, &ps);

// break;
// }

// case WM_ERASEBKGND:
// return 1;
Expand Down

0 comments on commit 7874b2e

Please sign in to comment.