Black cockpit canvas + flicker-free pane painting

SS_BLACKRECT paints the system window-frame color - gray on modern
Windows - so the viewscreen child is now a plain STATIC subclassed to
erase true black. The MFD/map panes flickered because Paint() cleared
the on-screen surface before redrawing at the fill cadence; the pane
now composes off screen and lands in a single BitBlt.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Cyd
2026-07-12 15:41:49 -05:00
co-authored by Claude Fable 5
parent 293e369656
commit 2a6398702c
2 changed files with 48 additions and 6 deletions
+21 -5
View File
@@ -323,11 +323,21 @@ void
RECT client;
GetClientRect((HWND) window, &client);
FillRect(hdc, &client, (HBRUSH) GetStockObject(BLACK_BRUSH));
SetStretchBltMode(hdc, COLORONCOLOR);
//---------------------------------------------------------------
// Double-buffered: compose the whole pane off screen and blit it
// in one operation, otherwise the clear-then-draw sequence
// flickers at the repaint cadence.
//---------------------------------------------------------------
HDC mem = CreateCompatibleDC(hdc);
HBITMAP surface = CreateCompatibleBitmap(hdc, client.right, client.bottom);
HBITMAP old_surface = (HBITMAP) SelectObject(mem, surface);
FillRect(mem, &client, (HBRUSH) GetStockObject(BLACK_BRUSH));
SetStretchBltMode(mem, COLORONCOLOR);
StretchDIBits(
hdc,
mem,
displayX, displayY, displayW, displayH,
0, 0, sourceWidth, sourceHeight,
pixels, (const BITMAPINFO *) blitHeader,
@@ -349,15 +359,21 @@ void
rect.bottom = button->y + button->h;
HBRUSH fill = CreateSolidBrush(ButtonFill(button->amber, level));
FillRect(hdc, &rect, fill);
FillRect(mem, &rect, fill);
DeleteObject(fill);
HBRUSH frame = CreateSolidBrush(
(i == pressedIndex) ? RGB(255, 255, 255) : RGB(48, 48, 48));
FrameRect(hdc, &rect, frame);
FrameRect(mem, &rect, frame);
DeleteObject(frame);
}
BitBlt(hdc, 0, 0, client.right, client.bottom, mem, 0, 0, SRCCOPY);
SelectObject(mem, old_surface);
DeleteObject(surface);
DeleteDC(mem);
EndPaint((HWND) window, &ps);
}