0

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

我正在尝试在不使用 EnabledVisualStyles() 的情况下使用选取框进度条。发生的事情是我的进度条没有任何动画出现。

矿:

在此处输入图像描述

应该是这样的:

在此处输入图像描述

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

4

2 回答 2

2

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

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

构建您的应用程序并在表单中拖动您的用户控件。根据您的要求修改代码和变量的值。

于 2016-12-21T10:13:24.780 回答
1

您可以使用带有 gif 图像的图片框。

于 2016-12-22T11:38:52.287 回答