可以在 Vista/Win7 中使用 XP Visual Style 吗? [英] Possible to use XP Visual Style in Vista/Win7?

查看:25
本文介绍了可以在 Vista/Win7 中使用 XP Visual Style 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以在 Vista/Win7 中使用 XP 样式吗?如果是,是否可以为单个控件执行此操作.

It is possible to use the XP styles in Vista/Win7? If yes, is it possible to do it for a single control.

我知道我可以使用 SetWindowTheme() 一次关闭一个控件的视觉样式.我知道可以通过删除 EnableVisualStyles 调用来关闭整个 win 表单应用程序的视觉样式.

I know I can turn off visual styles one control at a time using SetWindowTheme(). I know it is possible to turn off visual styles for the whole win forms app by removing the EnableVisualStyles call.

我问的原因是因为在应用程序中,这将用于一个处于错误状态的控件,它的背景色变为红色.当应用程序在 Vista/Win7 下运行时,这不适用于 ComboBoxes.改变背景颜色只改变下拉列表而不改变实际控件.

The reason I ask is because in the application this would be used it a control in a error state has it's backcolor turned red. This does not work for ComboBoxes when the application is running under Vista/Win7. Changing the back color only changes for the drop down list not the actual control.

我还研究过让 BackColor 像在 XP 中那样更改组合框颜色,并且在视觉样式关闭时也没有发现任何方法可以轻松做到这一点.

I have also looked into getting the BackColor to change the combobox color like it does in XP and when visual styles are off but have found no way to easily do that either.

是的,这在 WPF 中很容易解决.../cry.:)

And yes this would be easily solved in WPF... /cry. :)

推荐答案

好吧,你已经知道该怎么做了.

Well, you already know how to do it.

using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

class MyComboBox : ComboBox {
    protected override void OnHandleCreated(EventArgs e) {
        base.OnHandleCreated(e);
        SetWindowTheme(this.Handle, "", "");
    }
    [DllImport("uxtheme.dll")]
    private static extern int SetWindowTheme(IntPtr hWnd, string appname, string idlist);
}

无论您做什么,对于习惯于看到她的 UI 设计启用了视觉样式的用户来说,它都会显得很奇怪.并勾选一个有视力障碍的人,这可能会让你在美国被起诉.Windows 窗体已经有一种非常好的方法来指示错误,ErrorProvider 就是为此而设计的.

No matter what you do, it will look starkly off to a user that's used to seeing her UI designs having visual styles turned on. And tick off one that has visual impairments, something that can get you sued in the USA. Windows Forms already has a very good way to indicate errors, the ErrorProvider was designed to do that.

这篇关于可以在 Vista/Win7 中使用 XP Visual Style 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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