如何获得窗口框架的颜色?

时间:2013-10-14 18:14:04

标签: windows qt styles

我试图读取常规窗口窗口边框(边框)的颜色。

似乎window->palette().color(QPalette::XXXX)会这样做,但是XXXX是什么?或者调色板不可能吗?如果是这样,怎么样?

1 个答案:

答案 0 :(得分:2)

您需要使用本机GetSysColorBrush函数:

QColor getWindowFrameColor() {
    // This is the only way to detect that a given color is supported
    HBRUSH brush = GetSysColorBrush(COLOR_ACTIVEBORDER);
    if (brush) {
        DWORD color = GetSysColor(COLOR_ACTIVEBORDER);
        return QColor(GetRValue(color), GetGValue(color), GetBValue(color));
        // calling DeleteObject(brush) is unnecessary, but would be harmless
    }
    return QColor();
}

我搜索了COLOR_ACTIVEBORDER的Qt源代码,唯一的另一种检索方法是在WebKit上运行一些自定义的javascript代码。

相关问题