是否可以在 Windows 窗体应用程序中使用主题颜色?
我通常会尽可能使用系统颜色设计 Windows 窗体应用程序,使其适合用户的偏好。但是可以使用主题颜色吗?
我意识到这在几个方面限制了你(必须运行支持它的 Windows 并且运行主题服务),所以如果它可以依赖于其他默认值,我当然会喜欢它,但因为我相当确定 99% 的用户都会可以使用它,如果可能的话我想使用它。
具体来说,对于较新的 Windows 版本(Vista 和 7),超链接等内容具有更柔和、更柔和的蓝色。旧的系统颜色没有为链接等定义任何内容,并且通常在选择和多样性方面更加有限(来自 95 天)。
尽管 WPF 可能有更好的支持,但我不能随意使用它。如果需要某些第三方实用程序、程序集等,则也需要免费使用。我不需要任何花哨的东西,但在一个完美的世界中,我可以做这样的事情:
linkLabel1.LinkColor = System.Drawing.ThemeColors.Hyperlink;
我是否只能使用默认的蓝色(0,0,255)并让它们看起来Vista 及以上版本的位置?如果需要的话,我什至会接受丑陋的 p/invoke 互操作方法......
I normally make use of System Colors whenever possible when designing Windows Forms applications just so that it'll fit in with the user's preferences. But is it possible to use Theme Colors?
I realize that this limits you in several ways (must be running Windows that supports it and has the Themes service running), so I would certainly like it if it could fall back on some other default, but since I'm fairly sure 99% of my users will have it available, I'd like to make use of it if possible.
Specifically, for newer Windows versions (Vista and 7), things like hyperlinks have a softer more pastel-ish blue. The old System Colors do not define anything for links and the like, and in general are much more limited (coming from the 95 days) in choices and variety.
Though WPF probably has better support, I'm not at liberty to use it. If some third party utility, assembly, or the like is necessary, it would also need to be free to use. I don't need anything that fancy, but in a perfect world I would be able to do something like this:
linkLabel1.LinkColor = System.Drawing.ThemeColors.Hyperlink;
Am I stuck just using the default Blue (0,0,255) and having them look out of place in Vista and above? I'll even settle for ugly p/invoke interop methods if need be...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我知道这是一个愚蠢的想法,但您可以检查操作系统版本,然后预加载一组颜色
I know that this is a stupid idea but you could check the OS version and then preload a set of colours
我想你知道这两个属性吗?
You are aware of these two properties I presume?