DwmExtendFrameIntoClientArea without Aero Glass

前端 未结 3 1316
遥遥无期
遥遥无期 2021-02-05 22:20

Using the DwmExtendFrameIntoClientArea API call with Aero Glass enabled works just fine. However, I want it to work when Aero Glass is disabled as well, like how it

3条回答
  •  甜味超标
    2021-02-05 22:47

    You need to paint the window background yourself. You should not actually hard-code the colors as previous posts have suggested, but use the theme functions to retrieve them, like so (semi-pseudocode):

    DWORD rgb;
    HANDLE hTheme = OpenThemeData(GetDesktopWindow(), L"WINDOW");
    GetThemeColor(hTheme, WP_CAPTION, CS_ACTIVE,
         ? TMT_FILLCOLORHINT : TMT_BORDERCOLORHINT, &rgb);
    
    // Can use these functions to retrieve the individual RGB values
    BYTE r = GetRValue(rgb);
    BYTE g = GetGValue(rgb);
    BYTE b = GetBValue(rgb);
    

    These colors will remain correct even if the user changes title bar colors in the control panel (unlike using COLOR_ACTIVECAPTION / COLOR_GRADIENTACTIVECAPTION). You should also check that themes are active using IsThemeActive() before attempting to get theme colors.

    The values of the constants for quick reference:

    • WP_CAPTION: 1
    • CS_ACTIVE: 1
    • TMT_FILLCOLORHINT: 3821
    • TMT_BORDERCOLORHINT: 3822

提交回复
热议问题