vb6.0进度条progressbar自定义颜色
1个回答
展开全部
给你举个例子,是改进度条颜色滴,自己延伸下吧~
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long
Private Const WM_USER = &H400
Private Const PBM_SETBARCOLOR = (WM_USER + 9)
Private Function SetProgressBarColor(TargetProgressBar As ProgressBar) '进度条的颜色
SendMessage TargetProgressBar.hwnd, PBM_SETBARCOLOR, 0, ByVal RGB(IIf(TargetProgressBar.Value / TargetProgressBar.Max * 255 < 255 * 0.5, TargetProgressBar.Value / TargetProgressBar.Max * 255 * 2, 255), IIf(TargetProgressBar.Value / TargetProgressBar.Max * 255 < 255 * 0.5, 255, (255 - TargetProgressBar.Value / TargetProgressBar.Max * 255) * 2), 0)
End Function
Private Sub Command1_Click()
If ProgressBar1.Value < ProgressBar1.Max Then
ProgressBar1.Value = ProgressBar1.Value + 10
Else
ProgressBar1.Value = 0
End If
SetProgressBarColor ProgressBar1
End Sub
Private Sub Form_Load()
ProgressBar1.Max = 100
ProgressBar1.Value = 0
End Sub
'自己添加控件试下吧
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long
Private Const WM_USER = &H400
Private Const PBM_SETBARCOLOR = (WM_USER + 9)
Private Function SetProgressBarColor(TargetProgressBar As ProgressBar) '进度条的颜色
SendMessage TargetProgressBar.hwnd, PBM_SETBARCOLOR, 0, ByVal RGB(IIf(TargetProgressBar.Value / TargetProgressBar.Max * 255 < 255 * 0.5, TargetProgressBar.Value / TargetProgressBar.Max * 255 * 2, 255), IIf(TargetProgressBar.Value / TargetProgressBar.Max * 255 < 255 * 0.5, 255, (255 - TargetProgressBar.Value / TargetProgressBar.Max * 255) * 2), 0)
End Function
Private Sub Command1_Click()
If ProgressBar1.Value < ProgressBar1.Max Then
ProgressBar1.Value = ProgressBar1.Value + 10
Else
ProgressBar1.Value = 0
End If
SetProgressBarColor ProgressBar1
End Sub
Private Sub Form_Load()
ProgressBar1.Max = 100
ProgressBar1.Value = 0
End Sub
'自己添加控件试下吧
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询