所有版本的 Windows 上的 SystemColors 都相同吗? [英] Are SystemColors the same on all versions of Windows?

查看:31
本文介绍了所有版本的 Windows 上的 SystemColors 都相同吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.NET 框架包含定义所谓系统颜色"的类.对于 WinForms,它是 System.Drawing.SystemColors 对于 WP*,它是 System.Windows.SystemColors.我有两个问题:

The .NET framework contains classes which define so called "system colors". For WinForms it's System.Drawing.SystemColors and for WP* it's System.Windows.SystemColors. I have two questions regarding that:

  1. 系统颜色的默认值在所有版本的 Windows 上都相同吗?如果没有,我在哪里可以找到实际值?
  2. 系统颜色是否可配置?用户是否可以使用 SystemColors 全局更改所有应用程序的外观?
  1. Are the default values of system colors the same on all versions of Windows? If no where can i find the actual values?
  2. Are the system colors somehow configurable? Is it possible for the user to globally change the appearance of all applications using SystemColors?

如果颜色确实是可变的,并且我想保持我的应用程序的相同外观,而不管颜色和操作系统版本的用户配置如何,我假设我不能使用 SystemColors 而是创建我自己的颜色配置并在整个代码中使用它,对吗?

If the colors indeed are changeable and I want to maintain the same look of my application regardless of user configuration of colors and OS version i assume i must not use the SystemColors and instead create my own colors configuration and use it throughout the code, is that right?

推荐答案

如果你看看 KnownColorTable.cs 源代码,您将看到该类使用 Windows API GetSysColor 函数返回基于操作系统的颜色/用户配置.

If you take a look at KnownColorTable.cs source code, you will see the class gets the color using Windows API GetSysColor function which returns the color based on OS/user configurations.

以下是您问题的答案:

  1. 不,它们不一样.它们是操作系统/用户级别的配置.每个 Windows 主题都以不同的方式指定系统颜色.您可以自己调整系统颜色以创建自己的 Windows 主题

  1. No, they are not the same. They are configurations at OS/user level. Each Windows theme specifies the system colors differently. You can tweak the system colors yourself to create your own Windows theme

是的,您可以使用 SetSysColors 方法.此函数仅更改当前会话的颜色.要保持更改,您必须更新 HKEY_CURRENT_USER\Control Panel\Colors 处的注册表项.

Yes, you can change them programatically using SetSysColors method. This function changes the color for the current session only. To persist the change, you must update the registry keys at HKEY_CURRENT_USER\Control Panel\Colors.

其他资源:

  • 您会发现 WPF 团队博客中的这篇文章很有用:系统颜色参考
  • PInvoke 中的
  • SetSysColors 页面.网.该页面包含使用此方法以及使用注册表设置颜色的示例.

这篇关于所有版本的 Windows 上的 SystemColors 都相同吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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