Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Interface and Graphics > how to change progress bar color?


Reply
 
Thread Tools Display Modes
  #1  
Old 08-30-2003, 12:44 AM
deell deell is offline
Centurion
 
Join Date: Feb 2003
Posts: 188
Default how to change progress bar color?


in win9x, the progress bar color is blue. how to change it to other color?
and also winXP?
Reply With Quote
  #2  
Old 08-30-2003, 12:48 AM
poedguy's Avatar
poedguy poedguy is offline
Regular
 
Join Date: Aug 2003
Location: Perth, Western Australia
Posts: 78
Default

there is no way to change it with the common controls, there are plenty of other controls that have done this, like the vbAccelerator ProgressBar Control:
http://www.vbaccelerator.com/home/VB...ol/article.asp
__________________
poedguy
"Trust your Technolust"
Reply With Quote
  #3  
Old 08-30-2003, 11:19 PM
Squishy's Avatar
Squishy Squishy is offline
Senior Contributor
 
Join Date: Jul 2003
Location: Stratford
Posts: 919
Default

Actually, if you want a solid color, you can place a Label (.Caption = "") inside a PictureBox. Just stretch the PictureBox to whatever you want the maximum value/width to be, stretch the Label to match, then set the BackColor. Remember to set the Label's Top and Left to 0. To use it, just resize the PictureBox's width without sizing the Label. It's flicker-free, and you can also use a graphic to emulate the XP ProgressBar in every OS environment.
Reply With Quote
  #4  
Old 08-31-2003, 06:44 AM
Garrett Sever's Avatar
Garrett Sever Garrett Sever is offline
Strange Brewer

Retired Moderator
* Guru *
 
Join Date: Jun 2001
Location: AddressOf Insomnia
Posts: 2,815
Default

Quote:
Originally Posted by poedguy
there is no way to change it with the common controls,



That's totally wrong.

You can use the SendMessage API and PBM_SETBARCOLOR and PBM_SETBKCOLOR to change them.

The miracles of MSDN.
__________________
"The lights below
You know they'll bleed forever
Get back as the cores blow
Let me fall..." - Dismantled, "Cornered"
Reply With Quote
  #5  
Old 09-01-2003, 07:22 PM
deell deell is offline
Centurion
 
Join Date: Feb 2003
Posts: 188
Default

Quote:
Originally Posted by Garrett Sever
Quote:
Originally Posted by poedguy
there is no way to change it with the common controls,



That's totally wrong.

You can use the SendMessage API and PBM_SETBARCOLOR and PBM_SETBKCOLOR to change them.

The miracles of MSDN.



im not that advanced. but Photovoltaic idea is easy for me. thanks.
i will try pbm_setbarcolor & pbm_setbccolor. thanks.
Reply With Quote
  #6  
Old 09-01-2003, 08:03 PM
OnErr0r's Avatar
OnErr0r OnErr0r is offline
Obsessive OPtimizer

Administrator
* Guru *
 
Join Date: Jun 2002
Location: Debug Window
Posts: 13,685
Default

I like Garrett's idea, but if you really want to use a picturebox, do this:

(No label needed)

http://www.xtremevbtalk.com/show...24&postcount=3
Reply With Quote
  #7  
Old 09-02-2003, 03:11 AM
SpaceFrog's Avatar
SpaceFrog SpaceFrog is offline
Contributor
 
Join Date: May 2003
Location: Newt Galaxy
Posts: 542
Default

Code:
Function picture_Bar(ByRef startx, ByRef endx, ByVal Couleur As Long) Dim Ybar!, X! For X = startx To endx For Ybar = 0 To Picturebar.ScaleHeight Picturebar.PSet (X, Ybar), Couleur Next Ybar Next X DoEvents End Function ' Usage: 'initialise startx and endx 'if only to follow progression of a single operation startx = 0 'but you can have startx take last value of previous operation Call picture_Bar(startx, endx, vbWhite)
__________________
Life is a beach !
Reply With Quote
  #8  
Old 09-02-2003, 03:02 PM
OnErr0r's Avatar
OnErr0r OnErr0r is offline
Obsessive OPtimizer

Administrator
* Guru *
 
Join Date: Jun 2002
Location: Debug Window
Posts: 13,685
Default

PSet? Why not use Line? Check out the URL I posted.
Reply With Quote
  #9  
Old 09-03-2003, 01:36 AM
SpaceFrog's Avatar
SpaceFrog SpaceFrog is offline
Contributor
 
Join Date: May 2003
Location: Newt Galaxy
Posts: 542
Default

I use Pset because it allows me in some progressbars to insert percentage in the middle of bar and invert font colors so that percentage is visible all the time ...
__________________
Life is a beach !
Reply With Quote
  #10  
Old 09-03-2003, 10:05 AM
Thinker Thinker is offline
Iron-Fisted Programmer

Retired Moderator
* Guru *
 
Join Date: Jul 2001
Location: Fayetteville Arkansas USA
Posts: 18,127
Default

I don't see where you are doing any of those things in this example.
__________________
Posting Guidelines
Reply With Quote
  #11  
Old 09-03-2003, 10:22 AM
OnErr0r's Avatar
OnErr0r OnErr0r is offline
Obsessive OPtimizer

Administrator
* Guru *
 
Join Date: Jun 2002
Location: Debug Window
Posts: 13,685
Default

Spacefrog,
The code I posted does invert the colors for the percentage, and it's also centered in the picturebox.

Also, if you'd like a different color for the bar, just change the FillColor and ForeColor of the picturebox.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change the font color of Datagrid dynamically bill_jing Database and Reporting 0 09-24-2002 07:13 AM
Is it possible to change the back color of the standard Progress Bar? Mikirin General 1 04-09-2002 10:35 AM
Change Screen Color Resolution... OkeDech General 2 02-19-2002 07:26 AM
Input Box change color Bruno779 General 2 04-25-2001 02:05 AM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->