《创建setup类型的进度条》由会员分享,可在线阅读,更多相关《创建setup类型的进度条(3页珍藏版)》请在金锄头文库上搜索。
1、创建 setup 类型的进度条(vb6) 1.新建一个工程2.增加一个 picture box 和 command button 3.加入下面的代码:4.Dim tenth As Long5.条件编译6.#If Win32 Then7.Private Declare Function BitBlt Lib “gdi32“ _8.(ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, _9.ByVal nWidth As Long, ByVal nHeight As Long, _10.ByVal hSrcDC As Long, ByV
2、al xSrc As Long, ByVal ySrc As Long, _11.ByVal dwRop As Long) As Long12.#Else13.Private Declare Function BitBlt Lib “GDI“ (ByVal hDestDC As _14.Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth _15.As Integer, ByVal nHeight As Integer, ByVal hSrcDC As Integer, _16.ByVal xSrc As Integer,
3、ByVal ySrc As Integer, ByVal dwRop As _17.Long) As Integer18.#End If19.20.Sub UpdateStatus(FileBytes As Long)21.-22. 更新 Picture1 status bar23.-24. Static progress As Long25. Dim r As Long26. Const SRCCOPY = &HCC002027. Dim Txt$28. progress = progress + FileBytes29. If progress Picture1.ScaleWidth Th
4、en30. progress = Picture1.ScaleWidth31. End If32. Txt$ = Format$(CLng(progress / Picture1.ScaleWidth) * 100) + “%“33. Picture1.Cls34. Picture1.CurrentX = _35. (Picture1.ScaleWidth - Picture1.TextWidth(Txt$) 236. Picture1.CurrentY = _37. (Picture1.ScaleHeight - Picture1.TextHeight(Txt$) 238. Picture1
5、.Print Txt$39. Picture1.Line (0, 0)-(progress, Picture1.ScaleHeight), _40. Picture1.ForeColor, BF41. r = BitBlt(Picture1.hDC, 0, 0, Picture1.ScaleWidth, _42. Picture1.ScaleHeight, Picture1.hDC, 0, 0, SRCCOPY)43.End Sub44.45.Private Sub Command1_Click()46. Picture1.ScaleWidth = 10947. tenth = 1048. F
6、or i = 1 To 1149. Call UpdateStatus(tenth)50. x = Timer51. While Timer x + 0.7552. DoEvents53. Wend54. Next55.End Sub56.57.Private Sub Form_Load()58. Picture1.FontBold = True59. Picture1.AutoRedraw = True60. Picture1.BackColor = vbWhite61. Picture1.DrawMode = 1062. Picture1.FillStyle = 063. Picture1.ForeColor = vbBlue64.End Sub 65. F5 运行, 点击 Command1 就可以看到效果就可以看到效果.