龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 软件开发 > VB开发 >

利用VB2005制作颜色渐变的进度条[组图](7)

时间:2009-12-30 15:42来源:未知 作者:admin 点击:
分享到:
重载窗口绘制事件 Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) MyBase.OnPaint(e) 绘制外框 e.Graphics.FillRectangle(New SolidBrush(Me.BackColor), Me.Client

    '重载窗口绘制事件

    Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) 

        MyBase.OnPaint(e) 

        '绘制外框

        e.Graphics.FillRectangle(New SolidBrush(Me.BackColor), Me.ClientRectangle)

        '完成百分比

        Dim percentComplete As Single = CSng((m_Value - m_Minimum) / (m_Maximum - m_Minimum))

        If percentComplete <= 0.0F Then Exit Sub

        If percentComplete > 1.0F Then percentComplete = 1.0F 

        Dim fullWidth As Single

        '总宽度

        fullWidth = CSng(Me.ClientRectangle.Width - BorderWidth) 

        '当前百分比所占用的宽度

        Dim totalWidth As Single = fullWidth * percentComplete

        '每个画笔填充颜色占用的宽度

        Dim barWidth As Single

        barWidth = fullWidth 

        barWidth /= CSng(lstBrushes.Count) 

        Dim height As Single

        '起始宽度

        Dim halfBorder As Single = CSng(BorderWidth / 2)

        Dim idxColor As Integer = 0

        Dim x As Single 

精彩图集

赞助商链接