
Help: Progress Bar code generates Run Time Error 6
Hello all:
I copied this code from the VB KB and followed their instructions, but
alas, I'm getting a Runtime error code 6 on the line:
r = BitBlt(Picture1.hDC, 0, 0, Picture1.ScaleWidth....etc..
I'm running Windows NT and VB4 32bit. Any suggestions?? Thanks in
advance!
PS: if you cut and paste from my post, make sure all the lines that are
supposed to be on one line appear so in your code.
Dim tenth As Long
#If Win32 Then
Private Declare Function BitBlt Lib "GDI32" (ByVal hDestDC As Integer,
ByVal X As Integer, ByVal Y As Integer, ByVal nWidth As Integer, ByVal
nHeight As Integer, ByVal hSrcDC As Integer, ByVal XSrc As Integer,
ByVal YSrc As Integer, ByVal dwRop As Long) As Integer
#Else
Private Declare Function BitBlt Lib "GDI" (ByVal hDestDC As Integer,
ByVal X As Integer, ByVal Y As Integer, ByVal nWidth As Integer, ByVal
nHeight As Integer, ByVal hSrcDC As Integer, ByVal XSrc As Integer,
ByVal YSrc As Integer, ByVal dwRop As Long) As Integer
#End If
Sub UpdateStatus(FileBytes As Long)
'Update the Picture1 status bar
Static progress As Long
Const SRCCOPY = &HCC0020
Dim Txt$
progress = progress + FileBytes
If progress > Picture1.ScaleWidth Then
progress = Picture1.ScaleWidth
End If
Txt$ = Format$(CLng((progress / Picture1.ScaleWidth) * 100)) + "%"
Picture1.Cls
Picture1.CurrentX = (Picture1.ScaleWidth - Picture1.TextWidth(Txt$)) \ 2
Picture1.CurrentY = (Picture1.ScaleHeight - Picture1.TextHeight(Txt$)) \
2
Picture1.Print Txt$
Picture1.Line (0, 0)-(progress, Picture1.ScaleHeight),
Picture1.ForeColor, BF
r = BitBlt(Picture1.hDC, 0, 0, Picture1.ScaleWidth,
Picture1.ScaleHeight, Picture1.hDC, 0, 0, SRCCOPY)
End Sub
Private Sub Form_Load()
Picture1.AutoRedraw = True
Picture1.BackColor = &H80000003
Picture1.DrawMode = 10
Picture1.FillStyle = 0
Picture1.ForeColor = &H80
End Sub
Private Sub Command1_Click()
Picture1.ScaleWidth = 109
tenth = 10
For i = 1 To 10
Call UpdateStatus(tenth)
X = Timer
While Timer < X + 0.75
DoEvents
Wend
Next
End Sub
Ron