WindowsForm Theme

XP以后的系统支持一种叫做可视化风格的界面,界面可以随着系统的主题改变而变化。
程序必须明确的去启用这种风格,否则程序就是经典风格界面 ,程序界面不随系统主题而改变。
 
1.先看看操作系统是否支持 visual style
 
System.Windows.Forms.VisualStyles.VisualStyleInformation.IsSupportedByOS
System.Windows.Forms.VisualStyles.VisualStyleInformation.IsEnabledByUser
 
2.查看设置成什么
System.Windows.Forms.VisualStyles.VisualStyleInformation 上面
有一个非公开的属性名ThemeFilename
你也可以就用它暴露的
System.Windows.Forms.VisualStyles.VisualStyleInformation.DisplayName
 
这样获取了Aero style或者是其他种类的 style

明明这些属性都是true,但就是跑起来程序使用的是经典xp风格

只能试试用反射强行改属性值

typeof(Application).GetField("comCtlSupportsVisualStyles", BindingFlags.NonPublic | BindingFlags.Static).SetValue(null, true);
原文地址:https://www.cnblogs.com/chenyingzuo/p/15039429.html