Skip to content

进度条控件(ProgressBar) ​

封装 msctls_progress32 系统进度条控件,用于显示操作进度,支持标准、平滑、跑马灯等滚动模式及任务栏进度显示。

枚举 ​

PrbOrientationConstants ​

常量值说明
PrbOrientationHorizontal0水平方向
PrbOrientationVertical1垂直方向

PrbScrollingConstants ​

常量值说明
PrbScrollingStandard0标准模式
PrbScrollingSmooth1平滑滚动
PrbScrollingMarquee2跑马灯模式

PrbStateConstants ​

常量值说明
PrbStateNormal1正常状态
PrbStateError2错误状态(红色)
PrbStatePaused3暂停状态(黄色)

CCMousePointerConstants ​

参见通用枚举。

属性 ​

Min ​

vb
Property Get Min() As Long
Property Let Min(ByVal Value As Long)

最小值。

Max ​

vb
Property Get Max() As Long
Property Let Max(ByVal Value As Long)

最大值。

Value ​

vb
Property Get Value() As Long
Property Let Value(ByVal Value As Long)

当前值。

Step ​

vb
Property Get Step() As Long
Property Let Step(ByVal Value As Long)

步进增量。

StepAutoReset ​

vb
Property Get StepAutoReset() As Boolean
Property Let StepAutoReset(ByVal Value As Boolean)

StepIt 到达最大值时是否自动重置为最小值。

MarqueeAnimation ​

vb
Property Get MarqueeAnimation() As Boolean
Property Let MarqueeAnimation(ByVal Value As Boolean)

是否启用跑马灯动画。仅在 Scrolling 为 PrbScrollingMarquee 时有效。

MarqueeSpeed ​

vb
Property Get MarqueeSpeed() As Long
Property Let MarqueeSpeed(ByVal Value As Long)

跑马灯动画速度(毫秒)。仅在 Scrolling 为 PrbScrollingMarquee 时有效。

Orientation ​

vb
Property Get Orientation() As PrbOrientationConstants
Property Let Orientation(ByVal Value As PrbOrientationConstants)

进度条方向。

Scrolling ​

vb
Property Get Scrolling() As PrbScrollingConstants
Property Let Scrolling(ByVal Value As PrbScrollingConstants)

滚动模式。

SmoothReverse ​

vb
Property Get SmoothReverse() As Boolean
Property Let SmoothReverse(ByVal Value As Boolean)

是否启用平滑反转效果。需要 comctl32.dll 6.0 或更高版本。

BackColor ​

vb
Property Get BackColor() As OLE_COLOR
Property Let BackColor(ByVal Value As OLE_COLOR)

背景颜色。

ForeColor ​

vb
Property Get ForeColor() As OLE_COLOR
Property Let ForeColor(ByVal Value As OLE_COLOR)

前景颜色。

State ​

vb
Property Get State() As PrbStateConstants
Property Let State(ByVal Value As PrbStateConstants)

进度条状态(正常/错误/暂停)。

ShowInTaskBar ​

vb
Property Get ShowInTaskBar() As Boolean
Property Let ShowInTaskBar(ByVal Value As Boolean)

是否在任务栏上显示进度。需要 Windows 7 或更高版本。

Text ​

vb
Property Get Text() As String
Property Let Text(ByVal Value As String)

覆盖在进度条上的文本,支持占位符:{0} 为当前值,{1} 为最小值,{2} 为最大值,{3} 为百分比值。

TextColor ​

vb
Property Get TextColor() As OLE_COLOR
Property Let TextColor(ByVal Value As OLE_COLOR)

覆盖文本的颜色。

BorderStyle ​

vb
Property Get BorderStyle() As Integer
Property Let BorderStyle(ByVal Value As Integer)

边框样式(vbBSNone 或 vbFixedSingle)。

VisualStyles ​

vb
Property Get VisualStyles() As Boolean
Property Let VisualStyles(ByVal Value As Boolean)

是否启用视觉样式。

hWnd ​

vb
Property Get hWnd() As LongPtr

进度条控件的窗口句柄。

hWndUserControl ​

vb
Property Get hWndUserControl() As LongPtr

用户控件的窗口句柄。

Font ​

vb
Property Get Font() As StdFont
Property Let Font(ByVal NewFont As StdFont)
Property Set Font(ByVal NewFont As StdFont)

字体。

Enabled ​

vb
Property Get Enabled() As Boolean
Property Let Enabled(ByVal Value As Boolean)

是否可用。

MousePointer ​

vb
Property Get MousePointer() As CCMousePointerConstants
Property Let MousePointer(ByVal Value As CCMousePointerConstants)

鼠标指针样式。参见通用枚举。

MouseIcon ​

vb
Property Get MouseIcon() As IPictureDisp
Property Let MouseIcon(ByVal Value As IPictureDisp)
Property Set MouseIcon(ByVal Value As IPictureDisp)

自定义鼠标图标。

MouseTrack ​

vb
Property Get MouseTrack() As Boolean
Property Let MouseTrack(ByVal Value As Boolean)

是否启用鼠标进入/离开跟踪。

Name ​

vb
Property Get Name() As String

控件名称。只读。

Tag ​

vb
Property Get Tag() As String
Property Let Tag(ByVal Value As String)

自定义数据。

Parent ​

vb
Property Get Parent() As Object

父对象。只读。

Container ​

vb
Property Get Container() As Object
Property Set Container(ByVal Value As Object)

容器对象。

Left ​

vb
Property Get Left() As Single
Property Let Left(ByVal Value As Single)

左边距。

Top ​

vb
Property Get Top() As Single
Property Let Top(ByVal Value As Single)

顶边距。

Width ​

vb
Property Get Width() As Single
Property Let Width(ByVal Value As Single)

宽度。

Height ​

vb
Property Get Height() As Single
Property Let Height(ByVal Value As Single)

高度。

Visible ​

vb
Property Get Visible() As Boolean
Property Let Visible(ByVal Value As Boolean)

是否可见。

ToolTipText ​

vb
Property Get ToolTipText() As String
Property Let ToolTipText(ByVal Value As String)

工具提示文本。

HelpContextID ​

vb
Property Get HelpContextID() As Long
Property Let HelpContextID(ByVal Value As Long)

帮助上下文 ID。

WhatsThisHelpID ​

vb
Property Get WhatsThisHelpID() As Long
Property Let WhatsThisHelpID(ByVal Value As Long)

"这是什么"帮助 ID。

DragIcon ​

vb
Property Get DragIcon() As IPictureDisp
Property Let DragIcon(ByVal Value As IPictureDisp)
Property Set DragIcon(ByVal Value As IPictureDisp)

拖拽图标。

DragMode ​

vb
Property Get DragMode() As Integer
Property Let DragMode(ByVal Value As Integer)

拖拽模式。

方法 ​

StepIt ​

vb
Public Sub StepIt()

按 Step 属性指定的增量推进当前位置。

Increment ​

vb
Public Sub Increment(ByVal Delta As Long)

按指定增量推进当前位置。

Drag ​

vb
Public Sub Drag([ByRef Action As Variant])

开始、结束或取消拖放操作。

SetFocus ​

vb
Public Sub SetFocus()

将焦点移至控件。

ZOrder ​

vb
Public Sub ZOrder([ByRef Position As Variant])

设置控件的 Z 顺序。

OLEDrag ​

vb
Public Sub OLEDrag()

启动 OLE 拖放操作。

Refresh ​

vb
Public Sub Refresh()

强制重绘控件。

事件 ​

Change ​

vb
Public Event Change()

Value 属性值发生改变时触发。

Click ​

vb
Public Event Click()

单击控件时触发。

DblClick ​

vb
Public Event DblClick()

双击控件时触发。

MouseDown ​

vb
Public Event MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

按下鼠标按钮时触发。

MouseUp ​

vb
Public Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

释放鼠标按钮时触发。

MouseMove ​

vb
Public Event MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

移动鼠标时触发。

MouseEnter ​

vb
Public Event MouseEnter()

鼠标进入控件时触发。

MouseLeave ​

vb
Public Event MouseLeave()

鼠标离开控件时触发。

KeyDown ​

vb
Public Event KeyDown(KeyCode As Integer, Shift As Integer)

按下按键时触发。

KeyUp ​

vb
Public Event KeyUp(KeyCode As Integer, Shift As Integer)

释放按键时触发。

KeyPress ​

vb
Public Event KeyPress(KeyChar As Integer)

按键字符输入时触发。

代码示例 ​

vb
' 标准进度条
ProgressBar1.Min = 0
ProgressBar1.Max = 100
ProgressBar1.Value = 0
ProgressBar1.Step = 10
ProgressBar1.StepIt

' 带文本覆盖的进度条
ProgressBar1.Min = 0
ProgressBar1.Max = 1000
ProgressBar1.Text = "正在处理 {3}%"
ProgressBar1.TextColor = vbWhite

' 跑马灯模式(不确定进度)
ProgressBar1.Scrolling = PrbScrollingMarquee
ProgressBar1.MarqueeAnimation = True
ProgressBar1.MarqueeSpeed = 30

' 任务栏进度显示(Windows 7+)
ProgressBar1.ShowInTaskBar = True
ProgressBar1.State = PrbStateNormal

VB6及其LOGO版权为微软公司所有