diff --git a/MUNGA_L4/L4MFDVIEW.cpp b/MUNGA_L4/L4MFDVIEW.cpp index a9c740f..f40d289 100644 --- a/MUNGA_L4/L4MFDVIEW.cpp +++ b/MUNGA_L4/L4MFDVIEW.cpp @@ -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); } diff --git a/MUNGA_L4/L4VB16.cpp b/MUNGA_L4/L4VB16.cpp index 677fa71..e7fc00c 100644 --- a/MUNGA_L4/L4VB16.cpp +++ b/MUNGA_L4/L4VB16.cpp @@ -3801,6 +3801,26 @@ void //######################################################################## //############################ SVGA640x480x16 ############################ //######################################################################## + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Single-window cockpit: the viewscreen child erases true black +// (SS_BLACKRECT paints the system window-frame gray on modern Windows). +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +static WNDPROC gViewscreenBaseProc = NULL; + +static LRESULT CALLBACK + ViewscreenBlackProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + if (message == WM_ERASEBKGND) + { + RECT client; + GetClientRect(hwnd, &client); + FillRect((HDC) wParam, &client, (HBRUSH) GetStockObject(BLACK_BRUSH)); + return 1; + } + return CallWindowProcA(gViewscreenBaseProc, hwnd, message, wParam, lParam); +} + SVGA16::SVGA16( int mode, int init_width, @@ -3916,14 +3936,20 @@ SVGA16::SVGA16( if (cockpit != NULL) { + // plain STATIC (SS_BLACKRECT actually paints the system + // window-frame GRAY on modern Windows), subclassed below to + // erase true black cockpitViewscreen = CreateWindowExA( 0, "STATIC", "", - WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | SS_BLACKRECT, + WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS, 0, 0, view_w, view_h, cockpit, NULL, GetModuleHandleA(NULL), NULL); if (cockpitViewscreen != NULL) { + gViewscreenBaseProc = (WNDPROC) SetWindowLongPtrA( + cockpitViewscreen, GWLP_WNDPROC, + (LONG_PTR) ViewscreenBlackProc); gMainPresentWindow = cockpitViewscreen; } }