0

I want to customize the window frame using DWM in win32 to get an appearance like VS2022 (draw menu on title bar) or Chrome (draw tabs on title bar), so I use the function DwmExtendFrameIntoClientArea with margin {0, 0, caption height, 0}. Unfortunately, it shows a white window border with 1-pixel width and white title bar area. I use the function DwmDefWindowProc to handle the system messages and show the system control buttons (min, max, close button). But I have no idea how to change the color of the window border and title bar background. If I paint in WM_PAINT, it may cover the system control buttons and looks weird. If I paint in WM_NCPAINT, the window shadow with WS_THICKFRAME style may disappear and need to draw which I feel is difficult to do.

Additionally, the 1-pixel width border may come from the following code:

if (message == WM_NCCALCSIZE) {
    auto client_area_needs_calculating = static_cast<bool>(wparam);
        if (client_area_needs_calculating) {
            auto parameters = reinterpret_cast<NCCALCSIZE_PARAMS*>(lparam);
            auto& requested_client_area = parameters->rgrc[0];
            requested_client_area.right -= GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXPADDEDBORDER);
            requested_client_area.left += GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXPADDEDBORDER);
            requested_client_area.bottom -= GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CXPADDEDBORDER);
            return 0;
            }
        }
ltiger
  • 1
  • 1
  • Have a look at [custom-chrome](https://github.com/oberth/custom-chrome). – YangXiaoPo-MSFT Feb 28 '22 at 09:17
  • It seems that the border color and title bar background are depended on the system theme, which is the same as what I can achieve but not what I want. Is there any method to use my specified color? @YangXiaoPo - MSFT – ltiger Feb 28 '22 at 16:35

0 Answers0