tags:

views:

131

answers:

4

Is there a possbility to disable animation of the progress bar?

I need it for some pocess which is paused and not running at the moment. An average user would think the process is running if the progress bar is being blinking.

The advice to create own progress bar control is not what I'm looking for.

+1  A: 

The standard means of communicating to a user that an action is either paused or can't be accurately measured is to use the marquee display style.

progressBar1.Style = ProgressBarStyle.Marquee;

This style ignores the Maximum and Value properties and displays a progress bar "segment" that continually moves across the progress bar and loops around (it doesn't fill the progress bar, it moves what looks like a section of the bar all the way across the control and around to the beginning again.)

Adam Robinson
Thanks. But I need MAximum and Value. The user need to see where the process was paused.
Vasiliy Borovyak
@Vasily: That's the only OS-independent procedure; if you're guaranteed Vista or 7, then SLak's answer should solve your problem.
Adam Robinson
A: 

What you will want to do is set the style on this control specifically to override the theme changes. This article gives you a bit of information.

Mitchel Sellers
http://www.codeproject.com/KB/cpp/ExtendedProgressbar.aspx looks good. But I doubt my boss would approve non-standard looking controls.
Vasiliy Borovyak
+3  A: 

You can use the Vista progress bar's paused state, like this.

SLaks
That's what I was looking for. Thank you. That project is great: http://windowsformsaero.codeplex.com/
Vasiliy Borovyak
Just ran into this same issue myself. One question though: would this solution also work for software that will run on XP, or is it Vista/Win7 exclusively?
Nailuj
@Nailuj: It will not work on XP
SLaks
A: 

You could override the OnPaint() of the progressbar. You don't actually need to rewrite the whole thing, you just have to inherit the progressbar and override OnPaint like this:

public class my_progress_bar : ProgressBar {
        public Brush brush;
        public my_progress_bar() {
            this.SetStyle(ControlStyles.UserPaint, true);
            brush = Brushes.ForestGreen;
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            //base.OnPaint(e);
            Rectangle rectangle = e.ClipRectangle;
            rectangle.Width = (int)(rectangle.Width * ((double)Value / Maximum)) - 4;
            ProgressBarRenderer.DrawHorizontalBar(e.Graphics, e.ClipRectangle);
            rectangle.Height = Height - 4;
            e.Graphics.FillRectangle(brush, 2, 2, rectangle.Width, rectangle.Height);
        }
    }
Auxiliary
You're misunderstanding `e.ClipRectangle`; this will not render correctly. Also, you need a Vista-style bar. Calling `ProgressBarRenderer.DrawHorizontalChunks` will make it somewhat better.
SLaks
`e.ClipRectangle` is the area that needs to be repainted. You should use `this.ClientRectangle`.
SLaks
As I said in my question "The advice to create own progress bar control is not what I'm looking for."
Vasiliy Borovyak