捐助郴维网
感谢您对郴维网的支持,你的支持将是郴维网持续发展的动力!
二维码
×
当前位置:郴维网 >API档案 > 正文
2 2017.06

SetSysColors

点击次数:1324 更新时间:2017-6-2 20:40:10  【打印此页

原文链接 -> 传送门

函数功能:

SetSysColors 函数用于设置指定显示元素的颜色。显示元素为窗口部分和系统显示屏上的显示区。


API 函数原型:

注释:_In_ 说明该参数是输入的。

BOOL WINAPI SetSysColors(
  _In_       int      cElements,
  _In_ const INT      *lpaElements,
  _In_ const COLORREF *lpaRgbValues
);



参数解析:

参数

含义

cElements

指定在 lpaElements 指向的数组中元素的数量

lpaElements

1. 指向一个整数数组,数组规定将要改变的显示元素
2. 针对一系列的显示元素,请参考 GetSysColor 函数

lpaRgbValues

1. COLORREF 值的一个数组,数组包含显示元素,新的红色,蓝色和蓝色的颜色值,显示元素由 lpaElements 参数指定
2. 使用 RGB 宏定义,得到一个 COLORREF



返回值:

1. 如果函数调用成功,返回值是非 0;

2. 如果函数调用失败,返回值是 0。

调用 GetLastError 函数可以获取更多错误信息。


备注:

SetSysColors 函数给所有窗口发送一个 WM_SYSCOLORCHANGE 信息,告知窗口要改变颜色。该函数也告知系统重新喷绘当前所有可见窗口的指定的部分。最好遵循用户指定的颜色设置。如果你是在写一个应用,使用户能改变颜色,那么使用这个函数很恰当。但是,这个函数只对当前区域起作用。系统结束时,新的颜色不会被保存。


演示:

下面的例子演示了 GetSysColor 函数和 SetSysColors 函数的使用。例子先获取窗口和活动标题的颜色,并显示红,绿,蓝(RGB)的十六进制值。接下来,例子使用 SetSysColor 函数将窗口的背景色变成浅灰色,把活动的标题栏变成深紫色。经过 10 秒延迟后,例子用 SetSysColors 函数恢复元素之前的颜色。

#include <windows.h>
#include <stdio.h>
#pragma comment(lib, "user32.lib")

void main()
{
    int aElements[2] = {COLOR_WINDOW, COLOR_ACTIVECAPTION};
    DWORD aOldColors[2];
    DWORD aNewColors[2];

    // Get the current color of the window background.

    aOldColors[0] = GetSysColor(aElements[0]);

    printf("Current window color: {0x%x, 0x%x, 0x%x}\n",
        GetRValue(aOldColors[0]),
        GetGValue(aOldColors[0]),
        GetBValue(aOldColors[0]));

    // Get the current color of the active caption.

    aOldColors[1] = GetSysColor(aElements[1]);

    printf("Current active caption color: {0x%x, 0x%x, 0x%x}\n",
        GetRValue(aOldColors[1]),
        GetGValue(aOldColors[1]),
        GetBValue(aOldColors[1]));

    // Define new colors for the elements

    aNewColors[0] = RGB(0x80, 0x80, 0x80);  // light gray
    aNewColors[1] = RGB(0x80, 0x00, 0x80);  // dark purple

    printf("\nNew window color: {0x%x, 0x%x, 0x%x}\n",
        GetRValue(aNewColors[0]),
        GetGValue(aNewColors[0]),
        GetBValue(aNewColors[0]));

    printf("New active caption color: {0x%x, 0x%x, 0x%x}\n",
        GetRValue(aNewColors[1]),
        GetGValue(aNewColors[1]),
        GetBValue(aNewColors[1]));

    // Set the elements defined in aElements to the colors defined
    // in aNewColors

    SetSysColors(2, aElements, aNewColors);

    printf("\nWindow background and active border have been changed.\n");
    printf("Reverting to previous colors in 10 seconds...\n");

    Sleep(10000);   

    // Restore the elements to their original colors

    SetSysColors(2, aElements, aOldColors);
}


需求:

Minimum supported client

Windows 2000 专业版 [仅桌面应用程序]

Minimum supported server

Windows 2000 服务器版 [仅桌面应用程序]

Header

Winuser.h (包含于 Windows.h)

Library

User32.lib

DLL

User32.dll


 

提示
郴维网为您提供各类专业服务:
软件开发,电脑配件销售,WIFI路由器销售,上门电脑维修,上门安装系统,系统安装,软、硬件安装,电脑除尘清灰,显示器维修,WIFI安装调试,服务器维护,数据恢复,密码破解,网络布线,网络检修,打印机维修,打印机加碳粉,苹果电脑安装系统,苹果电脑安装双系统,监控安装维护,电脑外包,笔记本电脑维修,餐饮、美容行业软件安装 等。。。。。。
点击次数:1324 更新时间:2017-6-2 20:40:10  【打印此页

上一条:IsWindowEnabled

下一条:SetTextColor

关键词推荐:郴州电脑城 郴州电脑维修公司 维修电脑公司 郴州软件开发 上门电脑维修 上门安装系统 笔记本电脑维修 郴州打印机维修 打印机加碳粉 电脑安装双系统 苹果电脑双系统 液晶显示器维修 联想笔记本维修 联想笔记本维修电话 戴尔笔记本维修电话 郴州戴尔笔记本维修 戴尔笔记本郴州维修点 华硕笔记本维修点 郴州华硕笔记本维修 郴州笔记本上网维修