Senin, 11 Agustus 2008

Merubah Warna Progressbar

- Command1 (CommandButton)
- Command2 (CommandButton)
- ProgressBar1 (ProgressBar - Ms Windows Common Control)
-------------------------------------------------------------------------------------
Const WM_USER = &H400
Const CCM_FIRST As Long = &H2000&
Const CCM_SETBKCOLOR As Long = (CCM_FIRST + 1)
Const PBM_SETBKCOLOR As Long = CCM_SETBKCOLOR
Const PBM_SETBARCOLOR As Long = (WM_USER + 9)

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 Sub SetPBarColor(hwndProgBar As Long, ByVal clrref As Long)
Call SendMessage(hwndProgBar, PBM_SETBARCOLOR, 0&, ByVal clrref)
End Sub
Private Sub SetPBackColor(hwndProgBar As Long, ByVal clrref As Long)
Call SendMessage(hwndProgBar, PBM_SETBKCOLOR, 0&, ByVal clrref)
End Sub

Private Sub Command1_Click()
SetPBarColor ProgressBar1.hwnd, vbRed
End Sub

Private Sub Command2_Click()
SetPBackColor ProgressBar1.hwnd, vbGreen
End Sub

Private Sub Timer1_Timer()
If ProgressBar1.Value < 100 Then
ProgressBar1.Value = ProgressBar1.Value + 5
Else
ProgressBar1.Value = 0
End If
End Sub

1 komentar:

NEwbie mengatakan...

Thanks , ini yang dicari.. dan sukses running untuk vb6..