强制应用程序的 Windows 经典主题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2104582/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 13:47:51  来源:igfitidea点击:

Force Windows Classic Theme for Application

c#.netwindowswinforms

提问by monO

Hey Guys, I've searched around for this question but couldn't come up with anything.

嘿伙计们,我已经搜索了这个问题,但找不到任何东西。

The Problem:

问题:

If a user changes the Color Scheme on their Windows Desktop, it tweaks some functionality in my .net application.

如果用户更改其 Windows 桌面上的配色方案,它会调整我的 .net 应用程序中的某些功能。

Is there any way for me to FORCE my application to use the Windows Classic Theme, regardless of what the user's theme has been set as?

无论用户的主题设置为什么,有什么方法可以强制我的应用程序使用 Windows 经典主题?

Thanks!

谢谢!

回答by rerun

At startup set this property on the application object.

在启动时在应用程序对象上设置此属性。

Application.VisualStyleState = System.Windows.Forms.VisualStyles.VisualStyleState.NoneEnabled;

回答by stakx - no longer contributing

If you are using Visual Studio: when you go to your application project's properties, you will find a checkbox Enable XP Visual Styles. If you disable that, no theming should be applied to your application. I assume this is equivalent to uncommenting the line of code that user nobugz mentioned.

如果您使用的是 Visual Studio:当您转到应用程序项目的属性时,您会发现一个复选框Enable XP Visual Styles。如果您禁用它,则不应将主题应用于您的应用程序。我认为这相当于取消注释用户 nobugz 提到的代码行。

回答by Gabriel Magana

I have done that using DevExpress (http://devexpress.com) controls, they have their own theming engine, and one of the included themes is the Windows Classic one. The themes even style the window borders, so it is a true complete look and feel control.

我已经使用 DevExpress ( http://devexpress.com) 控件完成了这项工作,它们有自己的主题引擎,其中包含的主题之一是 Windows 经典主题。主题甚至可以设置窗口边框的样式,因此它是真正完整的外观和感觉控制。

As to how to do it natively without a third party control, I do not know.

至于如何在没有第三方控制的情况下进行本地操作,我不知道。

Specifically, look here for the theming engine in the DevExpress control suite: http://devexpress.com/Products/NET/Controls/WinForms/Skins/

具体来说,请在此处查找 DevExpress 控件套件中的主题引擎:http: //devexpress.com/Products/NET/Controls/WinForms/Skins/