|
-
Jun 7th, 2001, 10:46 AM
#1
Thread Starter
Lively Member
Color Change
Does anyone know how to change the colour of a Progress Bar.
Regards
IJ...
-
Jun 7th, 2001, 10:54 AM
#2
Registered User
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
-
Jun 7th, 2001, 10:59 AM
#3
Thread Starter
Lively Member
Thanks,
But I want to know how to change the Progress Bar's colour.
Can it be done ?
Cheers,
IJ...
-
Jun 7th, 2001, 01:57 PM
#4
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
-
Jun 7th, 2001, 06:33 PM
#5
Addicted Member
Constants
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
-
Jun 7th, 2001, 06:41 PM
#6
To get a list of API functions and constants, go to http://www.vbapi.com and download the API-Guide and the API-ToolShed.
-
Jun 7th, 2001, 06:56 PM
#7
API-ToolShed has the constants, and API-guide has the documentation of the functions.
-
Jun 7th, 2001, 07:19 PM
#8
API ToolShed & Guide are great but Megatron neglected to mention they are found at
allapi.net
-
Jun 8th, 2001, 01:31 PM
#9
Addicted Member
Hmmmmmmmmm..............
Hmmmmmmmmmmmmmm, that's how you raise the counter....
hehehehehe... (just kidding of course ;-))))))))))))))))))) )
-
Jun 8th, 2001, 02:52 PM
#10
Originally posted by jim mcnamara
API ToolShed & Guide are great but Megatron neglected to mention they are found at[/URL]
I was posting a follow up to Matthew Gates's response. (I presumed that he posted the right link)
-
Jun 8th, 2001, 03:10 PM
#11
My bad, I meant http://www.allapi.net, sorry about that Megatron and jim mcnamara .
-
Sep 14th, 2001, 08:50 AM
#12
Lively Member
Little Mistake...
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|