利用VB2005制作颜色渐变的进度条[组图](7)
'重载窗口绘制事件
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