以前写了一个 在窗体上添加一个ProgressBar1Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As LongSub ProgressSetColor(lProgressBarHwnd As Long, lColour As Long, bForeground As Boolean) Const WM_USER = &H400, CCM_FIRST As Long = &H2000& Const CCM_SETBKCOLOR As Long = (CCM_FIRST + 1), PBM_SETBKCOLOR As Long = CCM_SETBKCOLOR Const PBM_SETBARCOLOR As Long = (WM_USER + 9)
On Error GoTo ErrFailed If bForeground Then Call SendMessage(lProgressBarHwnd, PBM_SETBARCOLOR, 0&, ByVal lColour) Else Call SendMessage(lProgressBarHwnd, PBM_SETBKCOLOR, 0&, ByVal lColour) End If Exit SubErrFailed: Debug.Print "Error in ProgressSetColor: " & Err.Description Debug.Assert False End SubPrivate Sub Form_Load() ProgressSetColor ProgressBar1.hwnd, RGB(255, 0, 0), True ProgressSetColor ProgressBar1.hwnd, RGB(192, 192, 192), False ProgressBar1.Value = 50End Sub
以前写了一个 在窗体上添加一个ProgressBar1Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As LongSub ProgressSetColor(lProgressBarHwnd As Long, lColour As Long, bForeground As Boolean) Const WM_USER = &H400, CCM_FIRST As Long = &H2000& Const CCM_SETBKCOLOR As Long = (CCM_FIRST + 1), PBM_SETBKCOLOR As Long = CCM_SETBKCOLOR Const PBM_SETBARCOLOR As Long = (WM_USER + 9)
On Error GoTo ErrFailed If bForeground Then Call SendMessage(lProgressBarHwnd, PBM_SETBARCOLOR, 0&, ByVal lColour) Else Call SendMessage(lProgressBarHwnd, PBM_SETBKCOLOR, 0&, ByVal lColour) End If Exit SubErrFailed: Debug.Print "Error in ProgressSetColor: " & Err.Description Debug.Assert False End SubPrivate Sub Form_Load() ProgressSetColor ProgressBar1.hwnd, RGB(255, 0, 0), True ProgressSetColor ProgressBar1.hwnd, RGB(192, 192, 192), False ProgressBar1.Value = 50End Sub
在窗体上添加一个ProgressBar1Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As LongSub ProgressSetColor(lProgressBarHwnd As Long, lColour As Long, bForeground As Boolean)
Const WM_USER = &H400, CCM_FIRST As Long = &H2000&
Const CCM_SETBKCOLOR As Long = (CCM_FIRST + 1), PBM_SETBKCOLOR As Long = CCM_SETBKCOLOR
Const PBM_SETBARCOLOR As Long = (WM_USER + 9)
On Error GoTo ErrFailed
If bForeground Then
Call SendMessage(lProgressBarHwnd, PBM_SETBARCOLOR, 0&, ByVal lColour)
Else
Call SendMessage(lProgressBarHwnd, PBM_SETBKCOLOR, 0&, ByVal lColour)
End If
Exit SubErrFailed:
Debug.Print "Error in ProgressSetColor: " & Err.Description
Debug.Assert False
End SubPrivate Sub Form_Load()
ProgressSetColor ProgressBar1.hwnd, RGB(255, 0, 0), True
ProgressSetColor ProgressBar1.hwnd, RGB(192, 192, 192), False
ProgressBar1.Value = 50End Sub
在窗体上添加一个ProgressBar1Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As LongSub ProgressSetColor(lProgressBarHwnd As Long, lColour As Long, bForeground As Boolean)
Const WM_USER = &H400, CCM_FIRST As Long = &H2000&
Const CCM_SETBKCOLOR As Long = (CCM_FIRST + 1), PBM_SETBKCOLOR As Long = CCM_SETBKCOLOR
Const PBM_SETBARCOLOR As Long = (WM_USER + 9)
On Error GoTo ErrFailed
If bForeground Then
Call SendMessage(lProgressBarHwnd, PBM_SETBARCOLOR, 0&, ByVal lColour)
Else
Call SendMessage(lProgressBarHwnd, PBM_SETBKCOLOR, 0&, ByVal lColour)
End If
Exit SubErrFailed:
Debug.Print "Error in ProgressSetColor: " & Err.Description
Debug.Assert False
End SubPrivate Sub Form_Load()
ProgressSetColor ProgressBar1.hwnd, RGB(255, 0, 0), True
ProgressSetColor ProgressBar1.hwnd, RGB(192, 192, 192), False
ProgressBar1.Value = 50End Sub
有源代码
如果需要请留e-mail
我要是正是这种效果,谢谢!