开发者

ProgressBar Control no effect if its style is ProgressBarStyle.Marquee

I am trying to test progress bar with marquee style but with no succeed

    private void Form1_Load(object sender, EventArgs e)
    {
        Application.EnableVisualStyles();

        this.progressBar1.Style = Prog开发者_开发技巧ressBarStyle.Marquee;
        this.progressBar1.MarqueeAnimationSpeed = 100;
        //this.progressBar1.Value = 0;
    }

Update: At MSDN

The Marquee style is only supported in Windows XP Home Edition, Windows XP Professional x64 Edition, Windows Server 2003 Platform could this be the problem?

Update2: It seems the problem with a theme I installed on my machine not on the xp version... I removed the theme and the problem is just gone!


The way that several of the answers are reading the documentation is completely incorrect. In fact, the marquee style is fully supported on all versions of Windows XP, including 32-bit Home & Professional, as well as the x64 Edition (which really has more in common with Windows Server 2003 than XP). The reason that you know without a doubt that all of these operating systems support the control is because they all include the identical version of comctrl32.dll, which is what provides the implementation for the progress bar control.

I myself have used this style many times in applications, including those that run on Windows XP, and have never had a problem. In fact, as I mentioned in a comment, these versions of the operating system use this style of progress bar internally in several of the shell dialogs.

I've been challenged to provide code that demonstrates this apparently evasive phenomenon... I'm not really sure how to do that, as the code shown in the question works just fine for me. So I guess I'll just reprint that here, along with some screenshots:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();

        this.progressBar1.Style = ProgressBarStyle.Marquee;
        this.progressBar1.MarqueeAnimationSpeed = 100;
    }
}

Running under Windows XP with the Luna theme enabled:

   

ProgressBar Control no effect if its style is ProgressBarStyle.Marquee

And running under Windows XP with the Classic theme enabled:

   

ProgressBar Control no effect if its style is ProgressBarStyle.Marquee

This is all from a clean virtual machine with Windows XP Professional SP3 32-bit loaded. For proof:

ProgressBar Control no effect if its style is ProgressBarStyle.Marquee

Edit: It appears that if you have a custom theme installed, the marquee style may not show up correctly. Check your settings in the Display control panel. The built-in Luna (Windows XP) and Classic themes work correctly, as does the unofficial "Watercolor" theme. Theme designers are responsible for designing these elements and incorporating them into their themes. If you notice that your theme does not support this style, please contact the source for an update.


You should call EnableVisualStyle before you create form.

[STAThread]
static void Main()
{
    Application.EnableVisualStyles();
    Application.Run(new Form1());
}

From MSDN:

To have an effect, EnableVisualStyles() must be called before creating any controls in the application; typically, EnableVisualStyles() is the first line in the Main function


Most likely the answer is found in this extract from the documentation:

Windows XP Home Edition, Windows XP Professional x64 Edition, Windows Server 2003 Platform Note: The Marquee style is supported only on these platforms.

I guess you are on a different platform.


Even though the answer was already given, for those who may encounter the problem it is possible that the progress bar has Maximum set to 0. In that case there will be no animation even with Style and MarqueeAnimationSpeed set to correct values.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜