C# 不带EnabledVisualStyles()的字幕进度条

C# 不带EnabledVisualStyles()的字幕进度条,c#,progress-bar,visual-styles,C#,Progress Bar,Visual Styles,我正在使用非托管EXE开发.NET解决方案。这意味着,我没有启用视觉样式 我试图在不使用EnabledVisualStyles()的情况下使用marquee ProgesBar。 发生的情况是,我的进度条显示时没有任何动画 地雷: 应该是这样的: 你知道这是否可能吗?有什么解决方法吗?创建用户控件,在其中放置一个面板,将其停靠在父容器中。采取一个定时器控制。 您的用户控制代码应该是: using System; using System.Collections.Generic; using

我正在使用非托管EXE开发.NET解决方案。这意味着,我没有启用视觉样式

我试图在不使用EnabledVisualStyles()的情况下使用marquee ProgesBar。 发生的情况是,我的进度条显示时没有任何动画

地雷:

应该是这样的:


你知道这是否可能吗?有什么解决方法吗?

创建用户控件,在其中放置一个面板,将其停靠在父容器中。采取一个定时器控制。 您的用户控制代码应该是:

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;
        }
    }
}
构建应用程序并在窗体中拖动用户控件。
根据您的要求修改代码和变量的值。

创建用户控件,在其中放置一个面板,将其停靠在父容器中。采取一个定时器控制。 您的用户控制代码应该是:

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;
        }
    }
}
构建应用程序并在窗体中拖动用户控件。
根据需要修改代码和变量的值。

您可以将图片框与gif图像一起使用。

您可以将图片框与gif图像一起使用