Marquee Progressbar without EnabledVisualStyles()

752 views Asked by At

I'm working on a .NET solution with an unmanaged EXE. This means, i have no VisualStyles enabled.

I'm trying to use a marquee progessbar without using EnabledVisualStyles(). What happened is that my progressbar appears without any animation.

Mine:

enter image description here

Should be like this:

enter image description here

Do you know if this is possible at all? And is there any workaround?

2

There are 2 answers

0
Mehul Patel On

Create User Control, take one panel in it, dock it in parent container. Take one timer control. Your user control code should like:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ProgressBar
{
    public partial class PBar : UserControl
    {
        public PBar()
        {
            InitializeComponent();
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }
        int incre = 0;

        private void timer1_Tick(object sender, EventArgs e)
        {
            int width = 15;
            int gap = 5;
            Graphics g = panel1.CreateGraphics();
            g.Clear(panel1.BackColor);
            SolidBrush blueBrush = new SolidBrush(Color.DarkBlue);
            g.FillRectangle(blueBrush, new Rectangle(new Point(incre, 0), new Size(width, panel1.Height - 1)));
            g.FillRectangle(blueBrush, new Rectangle(new Point(incre + width + gap, 0), new Size(width, panel1.Height - 1)));
            g.FillRectangle(blueBrush, new Rectangle(new Point(incre + 2 * (width + gap), 0), new Size(width, panel1.Height - 1)));
            g.FillRectangle(blueBrush, new Rectangle(new Point(incre + 3* (width + gap), 0), new Size(width, panel1.Height - 1)));

            incre += 10;
            if (incre > panel1.Width)
                incre = 0;
        }
    }
}

Build your application and drag your user control in your form. Modify code and variable's values as per your requirement.

0
MKumar On

You can use picture box with gif image.