繁体   English   中英

没有EnabledVisualStyles()的选取框进度条

[英]Marquee Progressbar without EnabledVisualStyles()

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

我正在尝试不使用EnabledVisualStyles()来使用选取框progessbar。 发生的事情是我的进度栏显示时没有任何动画。

矿:

在此处输入图片说明

应该是这样的:

在此处输入图片说明

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

创建用户控件,在其中放置一个面板,将其停靠在父容器中。 控制一个计时器。 您的用户控制代码应类似于:

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图像一起使用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM