^^ 创建setup类型的进度条(vb6) ^^

本文介绍如何使用VB6创建一个类似安装程序中的进度条。通过声明API函数BitBlt并结合Picturebox控件来更新进度显示,同时展示了完整的代码实例。

       ^^             创建setup类型的进度条(vb6)          ^^

  1. 新建一个工程
  2. 增加一个picture box和command button
  3. 加入下面的代码:Dim tenth As Long'条件编译#If Win32 ThenPrivate Declare Function BitBlt Lib "gdi32" _(ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, _ByVal nWidth As Long, ByVal nHeight As Long, _ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, _ByVal dwRop As Long) As Long#ElsePrivate 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 IfSub UpdateStatus(FileBytes As Long)'--------------------------------------------------------------------' 更新Picture1 status bar'--------------------------------------------------------------------    Static progress As Long    Dim r 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 SubPrivate Sub Command1_Click()    Picture1.ScaleWidth = 109    tenth = 10    For i = 1 To 11        Call UpdateStatus(tenth)        x = Timer        While Timer < x + 0.75            DoEvents        Wend    NextEnd SubPrivate Sub Form_Load()    Picture1.FontBold = True    Picture1.AutoRedraw = True    Picture1.BackColor = vbWhite    Picture1.DrawMode = 10    Picture1.FillStyle = 0    Picture1.ForeColor = vbBlueEnd Sub 


  4.  F5 运行, 点击 Command1就可以看到效果.



Trackback: http://tb.blog.youkuaiyun.com/TrackBack.aspx?PostId=5691


评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值