VB Code:
Public Sub DrawProgress(p_PictureBox As PictureBox, ByVal p_sngPercent As Single, p_lngBackColor As Long, p_lngForeColor As Long)
Dim strPercent As String
Dim intX As Integer
Dim intY As Integer
Dim intWidth As Integer
Dim intHeight As Integer
strPercent = Format$(Int(p_sngPercent)) & "%"
intWidth = p_PictureBox.TextWidth(strPercent)
intHeight = p_PictureBox.TextHeight(strPercent)
intX = p_PictureBox.Width / 2 - intWidth / 2
intY = p_PictureBox.Height / 2 - intHeight / 2
With p_PictureBox
.FillStyle = vbFSSolid
.BackColor = p_lngBackColor
.ForeColor = p_lngForeColor
.DrawMode = vbCopyPen
.CurrentX = intX
.CurrentY = intY
p_PictureBox.Print strPercent
.DrawMode = vbNotXorPen
End With
If p_sngPercent > 0 Then
p_PictureBox.Line (0, 0)-(p_PictureBox.Width * p_sngPercent / 100, p_PictureBox.Height), p_lngForeColor, BF
Else
p_PictureBox.Line (0, 0)-(p_PictureBox.Width, p_PictureBox.Height), p_lngBackColor, BF
End If
p_PictureBox.Refresh
End Sub
*****************Form*****************
VB Code:
Option Explicit
Dim i As Integer
Private Sub Form_Load()
Timer1.Interval = 50
End Sub
Private Sub Timer1_Timer()
theValue = value(i + 1)
End Sub
Private Sub UserControl_Initialize()
Picture1.Left = 0
Picture1.Top = 0
End Sub
Private Sub UserControl_Resize()
Picture1.Width = UserControl.Width
Picture1.Height = UserControl.Height
End Sub
Function value(i As Integer)
If i = 100 Then
i = 0
End If
i = i + 1
DrawProgress Picture1, i, vbWhite, vbBlue
End Function
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
i = PropBag.ReadProperty("ProgressValue", 0)
End Sub
Public Property Get theValue() As String
theValue = i
End Property
Public Property Let theValue(ByVal New_Value As String)
i = New_Value
PropertyChanged "ProgressValue"
theValue = value(i)
End Property
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Call PropBag.WriteProperty("ProgressValue", i, 0)
End Sub