home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Programmer'…arterly (Limited Edition) / Visual_Basic_Programmers_Journal_VB-CD_Quarterly_Limited_Edition_1995.iso / code / ch28code / progbar.cls < prev    next >
Encoding:
Text File  |  1995-07-30  |  1.2 KB  |  45 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "ProgressBar"
  6. Attribute VB_Creatable = False
  7. Attribute VB_Exposed = False
  8. Option Explicit
  9.  
  10. Private blnInit As Boolean
  11. Private picProgress As PictureBox
  12.  
  13. Public Property Get Initialized() As Boolean
  14.     Initialized = blnInit
  15. End Property
  16.  
  17. Public Sub Init(pic As PictureBox)
  18.     Set picProgress = pic
  19.     With picProgress
  20.         .AutoRedraw = True
  21.         .DrawMode = 10 'Not XOR Pen
  22.         .FillStyle = 0 'Solid
  23.         .ForeColor = RGB(0, 0, 128)
  24.     End With
  25.     blnInit = True
  26. End Sub
  27.  
  28. Public Sub Progress(iAmount As Integer)
  29. Dim strAmount As String
  30.     If Not blnInit Then
  31.         MsgBox "You MUST call the Init method before using this object!", _
  32.             vbCritical
  33.         Exit Sub
  34.     End If
  35.     strAmount = Format(iAmount / 100, "0%")
  36.     With picProgress
  37.         .Cls
  38.         .CurrentX = (.ScaleWidth - .TextWidth(strAmount)) \ 2
  39.         .CurrentY = (.ScaleHeight - .TextHeight(strAmount)) \ 2
  40.     End With
  41.     picProgress.Print strAmount
  42.     picProgress.Line (0, 0)-((picProgress.ScaleWidth / 100) _
  43.         * iAmount, picProgress.ScaleHeight), picProgress.ForeColor, BF
  44. End Sub
  45.