我使用的是Windows 7,所以我的进度条都是绿色的。我想要一些更简单的东西,也许类似于Windows 98进度条。Windows 98风格的进度条
有没有简单的方法来改变进度条的风格,还是我不得不手动重新创建它?
我使用的是Windows 7,所以我的进度条都是绿色的。我想要一些更简单的东西,也许类似于Windows 98进度条。Windows 98风格的进度条
有没有简单的方法来改变进度条的风格,还是我不得不手动重新创建它?
你不能轻易得到确切的 Win98的外观没有一个非常激烈的重写控制。但通过关闭视觉样式,可以获得简单的平淡蓝色进度条。像这样:
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
class SimpleProgressBar : ProgressBar {
protected override void OnHandleCreated(EventArgs e) {
base.OnHandleCreated(e);
if (Environment.OSVersion.Version.Major >= 6) {
SetWindowTheme(this.Handle, "", "");
}
}
[DllImport("uxtheme.dll")]
private static extern int SetWindowTheme(IntPtr hWnd, string appname, string idlist);
}
我现在还没有在XP机器上测试过这个...但是我怀疑如果您在应用程序的框架设置下关闭“Windows XP样式”,您会得到您要的内容。
我想关闭它的一个元素,而不是一切。 – Pieter 2010-10-08 19:24:39
步骤1:Download COMCTL32.ocx(版本5)。我相信版本5是可重新分发的,尽管版本6我认为不是。我链接的一个可能不是重新编写的那个,但那是我测试这些步骤的那个。
步骤2:自定义您的工具箱,并从“COM Components”选项卡(通过浏览它)中选择您下载的文件。
第3步:从新的工具箱条目中添加一个Progressbar。
注意:在设计器中,它仍然看起来有点像一个新的进度条。
我喜欢汉斯的回答,但是没有必要重写控件的类。您可以通过使用控件的句柄调用SetWindowTheme来从单个控件中删除Win7样式。这里有一个例子:
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace MyApplication
{
public partial class Form1 : Form
{
[DllImport("uxtheme", ExactSpelling = true, CharSet = CharSet.Unicode)]
public extern static Int32 SetWindowTheme(IntPtr hWnd,
String textSubAppName, String textSubIdList);
public Form1()
{
InitializeComponent();
// Remove Win7 formatting from the progress bar.
SetWindowTheme(progressBar1.Handle, "", "");
一个很好的建议。保存我一个覆盖类。 – Nyerguds 2016-05-24 10:06:54
<3 Win98风格:) – 2010-10-08 19:34:20