Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Interface and Graphics > Colors


Reply
 
Thread Tools Display Modes
  #1  
Old 08-02-2004, 04:51 AM
knightingale knightingale is offline
Newcomer
 
Join Date: Jul 2004
Posts: 4
Default Colors


Can I add more colors/backcolors in the 'Palette'? (in VB 6.0)
-Thanks
Reply With Quote
  #2  
Old 08-02-2004, 07:23 AM
Ricardo Manuel's Avatar
Ricardo Manuel Ricardo Manuel is offline
Centurion
 
Join Date: May 2003
Location: Portugal
Posts: 157
Default

No, but you can create colors by using the rgb function for example
__________________
My Tutorials:
AlphaBlend / Non-Square AlphaBlend
Reply With Quote
  #3  
Old 08-03-2004, 03:25 AM
Ricardo Manuel's Avatar
Ricardo Manuel Ricardo Manuel is offline
Centurion
 
Join Date: May 2003
Location: Portugal
Posts: 157
Default

Reply to a private message.


RGB is the 3 primary colors Red, Green, Blue, this is also a VB function that "makes" the color that you want.

For example, if you want to change the background color of a form you can use this
Code:
Form1.BackColor = RGB(255,0, 0)

This will make the form pure red

You can use this in almost anything, the 3 values in the function are the 3 main colors, you just have to change the values of each one.

Each color goes from 0 to 255
__________________
My Tutorials:
AlphaBlend / Non-Square AlphaBlend
Reply With Quote
  #4  
Old 08-03-2004, 03:30 PM
pikzel_R pikzel_R is offline
Contributor

* Expert *
 
Join Date: Jul 2004
Posts: 484
Default VB IDE Color Palette Presets Dropdown

Quote:
Originally Posted by knightingale
Can I add more colors/backcolors in the 'Palette'? (in VB 6.0) -Thanks
Are you refereing to the VB IDE Color Palette Presets Dropdown (see picture below).

This is not actually the "palette". It's just a color picker dropdown with a few preset colors. The whole color range is accessed by using the correct hex values.

Is your understanding of how to set hex values (&H00000000) a little rusty? Like how do i change the hex values to get the color you want...?

I posted an extended colors Enum, which will allow you to add some additional color constants to your project.

Normally, there's only a few primary color constants built-in to VB6 like 'vbWhite', 'vbRed', etc. But what if want "vbDarkOrange', or 'vbPaleCyan', or 'vbLightPurple'?

That's where the Enum comes in. It's basically just a list of add-on color constants that allow you to use color names instead of hex values.

The extended Color Enum is on this post (along with an MSDN reference for QBColors):
http://www.xtremevbtalk.com/showpost.php?p=805390

oh, and since you may be a newbie and are wondering where do I put the Enum? If you have a module in your project it can go at the top of the module code...if you just have a form, it can go at the top of form code (in the General Declarations section, underneath 'Option Explicit' (If you are using 'Option Explicit' which hopefuly you are )

Then in the Form Load event it could be used like:
Code:
Private Sub Form_Load() Form1.BackColor = vbPaleYellow End Sub
Attached Images
File Type: jpg VB_Color_Palette_Presets.jpg (55.5 KB, 13 views)

Last edited by pikzel_R; 08-03-2004 at 03:45 PM.
Reply With Quote
  #5  
Old 08-04-2004, 09:32 AM
chosy chosy is offline
Junior Contributor
 
Join Date: Feb 2004
Location: Denmark
Posts: 235
Default

hey when i do..


Form1.BackColor = RGB(255,0, 0)


it says

Compile error

invalid outside procedure
Reply With Quote
  #6  
Old 08-04-2004, 09:37 AM
OnErr0r's Avatar
OnErr0r OnErr0r is offline
Obsessive OPtimizer

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

Quote:
Originally Posted by chosy
hey when i do..


Form1.BackColor = RGB(255,0, 0)


it says

Compile error

invalid outside procedure
That's because you can't put code just anywhere. Procedures are Subs or Functions. Put your code in a procedure.
__________________
Quis custodiet ipsos custodues.
Reply With Quote
  #7  
Old 08-04-2004, 10:45 AM
chosy chosy is offline
Junior Contributor
 
Join Date: Feb 2004
Location: Denmark
Posts: 235
Default

oh lol okies ty :lol:

Last edited by chosy; 08-04-2004 at 11:05 AM.
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

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
 
 
-->