找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 194|回复: 0

使用PictureBox模拟进度条

[复制链接]

27

主题

11

回帖

151

积分

管理员

积分
151
发表于 2024-4-5 23:37:31 | 显示全部楼层 |阅读模式
不光是模拟进度条,还支持字符反显
源代码网址:
http://www.extencent.com/show.asp?id=199
源代码:
'代码经过测试,不闪烁

  1. Public Sub SetProgress(PBar As PictureBox, ByVal Value As Long, ByVal Max As Long, Optional ByVal Describe As String = "")
  2.     Dim showText As String
  3.     Dim drawLength As Long
  4.    
  5.     drawLength = (Value * PBar.ScaleWidth / Max)
  6.    
  7.     If Describe = "" Then
  8.         showText = Format(Value * 100 / Max, "#0.00") & "%"
  9.     Else
  10.         showText = Describe
  11.     End If
  12.    
  13.     With PBar
  14.         .AutoRedraw = True
  15.         .Cls
  16.         .CurrentX = (.ScaleWidth - .TextWidth(showText)) / 2
  17.         .CurrentY = (.ScaleHeight - .TextHeight(showText)) / 2
  18.         .FontBold = True
  19.         PBar.Print showText
  20.         .DrawMode = 8
  21.         PBar.Line (0, 0)-(drawLength, .ScaleHeight), Not RGB(51, 153, 255), BF
  22.         .AutoRedraw = False
  23.         .Refresh
  24.     End With
  25. End Sub
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|编程客 ( 鄂ICP备19023849号-1 )

GMT+8, 2025-6-13 07:39 , Processed in 0.034030 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表