且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Windows 8中获取活动窗口的标题颜色

更新时间:2023-01-27 11:38:57

DWORD WINAPI GetSysColor(
 _In_  int nIndex
 );

对于 GetSysColor()函数,如果 nIndex 参数超出范围,则返回值为零.因为零也是有效的RGB值,所以您不能使用 GetSysColor()来确定当前平台是否支持系统颜色.而是使用 GetSysColorBrush()函数,如果不支持该颜色,则该函数将返回 NULL .

For the GetSysColor() function, if the nIndex parameter is out of range, the return value is zero. Because zero is also a valid RGB value, you cannot use GetSysColor() to determine whether a system color is supported by the current platform. Instead, use the GetSysColorBrush() function, which returns NULL if the color is not supported.

单击以查看语法和用法.

另一种选择是使用 DwmGetColorizationColor()函数,该函数可以检索用于 Desktop Window Manager(DWM)玻璃组成的当前颜色.该值基于当前的配色方案,并且可以由用户修改.应用程序可以通过处理 WM_DWMCOLORIZATIONCOLORCHANGED 通知来侦听颜色变化.

Another option is to use the DwmGetColorizationColor() function which can retrieve the current color used for Desktop Window Manager (DWM) glass composition. This value is based on the current color scheme and can be modified by the user. Applications can listen for color changes by handling the WM_DWMCOLORIZATIONCOLORCHANGED notification.

HRESULT WINAPI DwmGetColorizationColor(
  _Out_  DWORD *pcrColorization,
  _Out_  BOOL *pfOpaqueBlend
);