📄 ctrl_progressbar.ctl
字号:
VERSION 5.00
Begin VB.UserControl ctrl_ProgressBar
AutoRedraw = -1 'True
BackStyle = 0 '透明
ClientHeight = 480
ClientLeft = 0
ClientTop = 0
ClientWidth = 1320
ScaleHeight = 480
ScaleWidth = 1320
ToolboxBitmap = "ctrl_ProgressBar.ctx":0000
Begin VB.PictureBox pic_ProgressBar
AutoRedraw = -1 'True
AutoSize = -1 'True
Height = 495
Left = 0
ScaleHeight = 435
ScaleWidth = 1155
TabIndex = 1
Top = 480
Visible = 0 'False
Width = 1215
End
Begin VB.PictureBox pic_Progress
AutoRedraw = -1 'True
AutoSize = -1 'True
BorderStyle = 0 'None
Height = 495
Left = 0
ScaleHeight = 495
ScaleWidth = 1215
TabIndex = 0
Top = 0
Width = 1215
End
End
Attribute VB_Name = "ctrl_ProgressBar"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
Private 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
Private Const SRCCOPY = &HCC0020
Private Type POINTAPI
X As Long
Y As Long
End Type
Public SkinPath As String
Const DefMin = 1
Const DefMax = 80
Const DefJumpStep = 1
Dim v_iMin As Integer
Dim v_iMax As Integer
Dim v_iJumpStep As Integer
Dim v_iValue As Integer
Public Sub LoadSkin()
Dim v_lRtn As Long
Dim v_iCenterImgFrequency As Integer
Dim v_iLoop As Integer
With UserControl
.pic_ProgressBar.Picture = LoadPicture(SkinPath & "\img_ProgressBar.bmp")
.pic_Progress.Width = .Width
.pic_Progress.Height = 240
.pic_Progress.Cls
v_lRtn = BitBlt(.pic_Progress.hdc, 0, 0, 6, 16, .pic_ProgressBar.hdc, 0, 0, SRCCOPY)
v_iCenterImgFrequency = Abs((.Width / Screen.TwipsPerPixelX) / 81)
If v_iCenterImgFrequency > 0 Then
For v_iLoop = 0 To v_iCenterImgFrequency - 1
v_lRtn = BitBlt(.pic_Progress.hdc, (v_iLoop * 80) + 6, 0, 80, 16, .pic_ProgressBar.hdc, 6, 0, SRCCOPY)
Next v_iLoop
End If
v_lRtn = BitBlt(.pic_Progress.hdc, (.Width / Screen.TwipsPerPixelX) - 5, 0, 5, 16, .pic_ProgressBar.hdc, 85, 0, SRCCOPY)
pic_Progress.Refresh
End With
End Sub
Public Sub Refresh()
Dim v_lRtn As Long
Dim v_iCenterImgFrequency As Integer
Dim v_iLoop As Integer
With UserControl
.pic_Progress.Cls
v_lRtn = BitBlt(.pic_Progress.hdc, 0, 0, 6, 16, .pic_ProgressBar.hdc, 0, 0, SRCCOPY)
v_iCenterImgFrequency = Abs((.Width / Screen.TwipsPerPixelX) / 81)
If v_iCenterImgFrequency > 0 Then
For v_iLoop = 0 To v_iCenterImgFrequency - 1
v_lRtn = BitBlt(.pic_Progress.hdc, (v_iLoop * 80) + 6, 0, 80, 16, .pic_ProgressBar.hdc, 6, 0, SRCCOPY)
Next v_iLoop
End If
v_lRtn = BitBlt(.pic_Progress.hdc, (.Width / Screen.TwipsPerPixelX) - 5, 0, 5, 16, .pic_ProgressBar.hdc, 85, 0, SRCCOPY)
pic_Progress.Refresh
End With
End Sub
Public Sub Progress()
Dim v_lRtn As Long
Dim v_iCenterImgFrequency As Integer
Dim v_iLoop As Integer
With UserControl
.pic_ProgressBar.Picture = .pic_Progress.Image
.pic_Progress.Width = .Width
.pic_Progress.Height = 240
.pic_Progress.Cls
v_lRtn = BitBlt(.pic_Progress.hdc, 0, 0, 6, 16, .pic_ProgressBar.hdc, 0, 0, SRCCOPY)
JumpStep = Int((UserControl.Width / 15) / (v_iMax - v_iMin))
If (v_iValue + JumpStep + 5) <= ((UserControl.Width / 15) - 85) Then
v_iValue = v_iValue + JumpStep + 5
v_iCenterImgFrequency = Abs((.Width / Screen.TwipsPerPixelX) / 80)
If v_iCenterImgFrequency > 0 Then
For v_iLoop = 0 To v_iCenterImgFrequency - 1
v_lRtn = BitBlt(.pic_Progress.hdc, (v_iLoop * 80) + 6, 0, 80, 16, .pic_ProgressBar.hdc, v_iValue, 0, SRCCOPY)
Next v_iLoop
End If
v_lRtn = BitBlt(.pic_Progress.hdc, (.Width / Screen.TwipsPerPixelX) - 6, 0, 6, 16, .pic_ProgressBar.hdc, 85, 0, SRCCOPY)
pic_Progress.Refresh
Else
Call Refresh
End If
End With
End Sub
Public Property Get Min() As Integer
Min = v_iMin
End Property
Public Property Let Min(ByVal m_Min As Integer)
v_iMin = m_Min
PropertyChanged "Min"
End Property
Public Property Get Max() As Integer
Max = v_iMax
End Property
Public Property Let Max(ByVal m_Max As Integer)
v_iMax = m_Max
PropertyChanged "Max"
End Property
Public Property Get JumpStep() As Integer
JumpStep = v_iJumpStep
End Property
Public Property Let JumpStep(ByVal m_JumpStep As Integer)
v_iJumpStep = m_JumpStep
PropertyChanged "JumpStep"
End Property
Private Sub UserControl_InitProperties()
v_iMin = DefMin
v_iMax = DefMax
v_iJumpStep = DefJumpStep
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
v_iMin = PropBag.ReadProperty("Min", DefMin)
v_iMax = PropBag.ReadProperty("Max", DefMax)
v_iJumpStep = PropBag.ReadProperty("JumpStep", DefJumpStep)
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Call PropBag.WriteProperty("Min", v_iMin, DefMin)
Call PropBag.WriteProperty("Max", v_iMax, DefMax)
Call PropBag.WriteProperty("JumpStep", v_iJumpStep, DefJumpStep)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -