VB6,新建一个工程,在界面中放置一个进度条控件,输入如下代码:
Option Explicit
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const PBM_SETBARCOLOR = &H409
Private Const PBM_SETBKCOLOR = &H2001
Private Sub Form_Load()
PostMessage ProgressBar1.hwnd, PBM_SETBARCOLOR, 0, vbRed
PostMessage ProgressBar1.hwnd, PBM_SETBKCOLOR, 0, vbGreen
ProgressBar1.Value = 30
End Sub