如何在Windows 8中获取活动窗口的标题颜色 [英] How to get the caption color of an active window in Windows 8

查看:60
本文介绍了如何在Windows 8中获取活动窗口的标题颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How can I get caption color of active window in Windows 8 ?

我尝试调用 GetSysColor(COLOR_ACTIVECAPTION),但是它返回了不同的颜色.这很奇怪,因为在Windows 7中它可以正常工作.还有其他方法如何获取活动窗口的标题颜色或任务栏的颜色吗?

I tried to call GetSysColor(COLOR_ACTIVECAPTION) but it returns different color. It's strange because in Windows 7 it works right. Is there any other way how to get caption color of active window or color of taskbar ?

推荐答案

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
);

这篇关于如何在Windows 8中获取活动窗口的标题颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆