Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Progrss Bar Color 2

Status
Not open for further replies.

Bubbler

IS-IT--Management
Joined
Dec 14, 2003
Messages
135
Location
US
Is there any way to change the color of the progress bar ctrl.
 
Why sure, place a progressbar onto a form and add this code...

[blue]Option Explicit

Private Declare Function [/blue]SendMessage [blue]Lib [/blue]"user32" [blue]Alias [/blue]"SendMessageA" _
([blue]ByVal [/blue]hwnd [blue]As Long[/blue], [blue]ByVal [/blue]wMsg [blue]As Long[/blue], [blue]ByVal [/blue]wParam [blue]As Long[/blue], _
lParam [blue]As [/blue]Any) As [blue]Long

Enum [/blue]PB_Colors
PB_SetBarColor = 1033
PB_SetBackColor = 8193
[blue]End Enum

Enum [/blue]LV_Colors
LVM_SETTEXTBKCOLOR = 4097 [green]'4096 + ?
[/green][blue]End Enum

Private Sub [/blue]Form_Load()
[blue]Dim [/blue]lngRet [blue]As Long

With [/blue]ProgressBar1
[green]' Set the bar color
[/green]lngRet = SendMessage(.hwnd, PB_SetBarColor, 0, [blue]ByVal [/blue]RGB(0, 255, 0))
[green]' Set the back color
[/green]lngRet = SendMessage(.hwnd, PB_SetBackColor, 0, [blue]ByVal [/blue]RGB(0, 0, 0))
.Value = 50
[blue]End With
End Sub
[/blue]
 
Thanks LPlates, works great. I looked around and there were several OCX solutions but I figured it must be able to be done simply in the form, and it was. :-)
 
So... on that note...

Are you able to change the ForeColor of a command button with a similar method ;-) ?

Have Fun, Be Young... Code BASIC
-Josh
cubee101.gif


PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Use a graphical style checkbox, you can change the forecolor.

If you want it to act like a command button place this line into the click event...

Private Sub Check1_Click()
Check1.Value = 0
' Do whatever here
End Sub

Hope this helps :-)
 
You can also use the progress bar control from the common controls replacement project ( It has the ability to change colour at design time or run time as well as other enhancements over the VB progress bar. It's a free download.

Take Care,

zemp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top