Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I use Windows 7, so my progress bars all have that green look. I'd like something a little more simplistic though, perhaps something resembling the Windows 98 progress bar.

Is there a simple way to change the style of the progress bar or will I have to recreate it manually?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
432 views
Welcome To Ask or Share your Answers For Others

1 Answer

You cannot easily get the exact Win98 look without a pretty drastic rewrite of the control. But a simple flat light-blue progress bar can be had by turning off visual styles. Like this:

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);
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...