Does anyone know how to change the colour of a Progress Bar.
Regards
IJ...:eek:
Printable View
Does anyone know how to change the colour of a Progress Bar.
Regards
IJ...:eek:
Make your own? Fancier ones exist at www.planetsourcecode.com
By Mark Sreeves
Code:Private Sub Command1_Click()
Static i As Integer
i = i + 1
UpdateProgress i
End Sub
Private Sub Form_Load()
Picture1.Tag = 100
Picture1.BackColor = 12582912 'change To whatever
End Sub
Private Sub UpdateProgress(ByVal iValue As Long)
On Error Resume Next
With Picture1
If iValue = 1 Then .Cls
Picture1.Line (0, 0)-Step((.ScaleWidth / .Tag) * iValue, .ScaleHeight), &HFF&, BF 'vbActiveTitleBar
End With
End SubstFile = stDir1 & stFile
FileCopy stFile, stDir2 & sNewFile
sCounter = sCounter + 1
ProgressBar1.Value = sCounter
stFile = Dir
Next x
End Sub
Private Sub Form_Load()
ProgressBar1.Max = 10
End Sub
Thanks,
But I want to know how to change the Progress Bar's colour.
Can it be done ?
Cheers,
IJ...
Try this:
VB Code:
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 Const PBM_SETBKCOLOR = &H2000 + 1 Public Function SetPBBackColor(ProgressBar As Object, _ NewColor As OLE_COLOR) As Boolean On Error Resume Next Dim lRet As Long lRet = SendMessage(ProgressBar.hwnd, PBM_SETBKCOLOR, 0&, NewColor) End Function Public Function SetPBBarColor(ProgressBar As Object, _ NewColor As OLE_COLOR) As Boolean On Error Resume Next Dim lRet As Long lRet = SendMessage(ProgressBar.hwnd, PBM_SETBARCOLOR, 0&, NewColor) End Function [b][u]Usage[/u][/b] SetPBBackColor ProgressBar1, vbRed
Alright guys,
I know how SendMessage function works, but how do you find the correct constants (messages) to send to each control ???? I have SOME listed but where do you get all of them ???
MSDN didn't help me much.
If anyone has a link or anything, please report..
Thanks,
Hyperspaced
To get a list of API functions and constants, go to http://www.vbapi.com and download the API-Guide and the API-ToolShed.
API-ToolShed has the constants, and API-guide has the documentation of the functions.
API ToolShed & Guide are great but Megatron neglected to mention they are found at
allapi.net
Hmmmmmmmmmmmmmm, that's how you raise the counter....
hehehehehe... (just kidding of course ;-))))))))))))))))))) )
I was posting a follow up to Matthew Gates's response. (I presumed that he posted the right link)Quote:
Originally posted by jim mcnamara
API ToolShed & Guide are great but Megatron neglected to mention they are found at[/URL]
My bad, I meant http://www.allapi.net, sorry about that Megatron and jim mcnamara ;).
Mathew - I belive you have missed out the 'ByVal' on the SendMessage call on the above example :-
VB Code:
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 Const PBM_SETBKCOLOR = &H2000 + 1 Public Function SetPBBackColor(ProgressBar As Object, _ NewColor As OLE_COLOR) As Boolean On Error Resume Next Dim lRet As Long lRet = SendMessage(ProgressBar.hwnd, PBM_SETBKCOLOR, 0&, [B]ByVal[/B] NewColor) End Function Public Function SetPBBarColor(ProgressBar As Object, _ NewColor As OLE_COLOR) As Boolean On Error Resume Next Dim lRet As Long lRet = SendMessage(ProgressBar.hwnd, PBM_SETBARCOLOR, 0&, [B]ByVal[/B] NewColor) End Function
just in case you missed it, I thought i'd put it in.