Solved

RGB/ VB colors

Posted on 2003-10-25
11
3,638 Views
Last Modified: 2007-12-19
quick question about colours.

the button face of Vb is &8000000F& does nayone know what the RGB equivalent is so i can make a background in paint

neutrino Dave

thx in advance
0
Comment
Question by:neutrinohunter
  • 3
  • 2
  • 2
  • +2
11 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 9620078
A color code that begins with &8 is not actually a specific color, but a specific color setting. (i.e. active window, inactive window, etc.)  The color code is defined at the system level by customizing the appearance of your system from the control panel.

With this in mind, that value you are looking for is dependent upon what is set on the target machine and can change at any time.

If you want to know the exact RGB values for YOUR system, however, donwload this neat little tool and run it.

http://www.itsfree4u.com/cgi-bin/load.cgi?http://koysoftware.hypermart.net/download/cs2.zip

Just click and drag the crosshairs from the "Picker" section on the right side of the form and pass it over anything on the screen to discover its RGB values.

Good luck and Happy Coding...

0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 9620096
a number like &H8000000F (which, by the way is the CORRECT notation) is in HEX (hexadecimal) and is the equivalent of the vaule of the Color when coded as SSRRGGBB where the SS, RR, BB, GG are the HEX values forthe Saturtion, RED, BLUE and GREEN values of the color.

The Long value of that color would be -2147483633

you can either parse the HEX string of the Number - &H8000000F  to get SS = 80 RR=00, GG=00 BB = 0F,  of you can simply use the CLng function to convert the Hex string to aLong, which is the value the the ForeGround color will accept (though I believe that it will ALSO accept a color as a HEX String with the leading &H :

&HSSRRGGBB remeber that Hex FF is 255.

AW

0
 
LVL 4

Expert Comment

by:SSSoftware
ID: 9620422
I think the SS portion of the color iis a flag that (when the hi bit is on) means to use the system color pallet so the color will follow the color scheme that the user configures his system.  

Therefore the SS tells the system to use the 16th (F) color (Indexes start at 0)in the system palette for this control.

 A different explination of the same thought:
When the Hi order bit is true then the number is an index into a color pallette,
not an absolute color.


Please corect me if I'm wrong.

Ed
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 9620920
I think Arthur_Wood is right in saying that the correct format would be &H8000000F.
However, neutrinohunter most likely made a typo and left the H out.  

According to the VB Help file, that number is a user definable System color and simply converting it to a long would probably not produce the desired RBG value.

The following is Directly from VB6.0 Help File:
-----------------------------------------------------
Using Direct Color Settings
Using the RGB function or the intrinsic constants to define color are indirect methods. They are indirect because Visual Basic interprets them into the single approach it uses to represent color. If you understand how colors are represented in Visual Basic, you can assign numbers to color properties and arguments that specify color directly. In most cases, it’s much easier to enter these numbers in hexadecimal.

The valid range for a normal RGB color is 0 to 16,777,215 (&HFFFFFF&). Each color setting (property or argument) is a 4-byte integer. The high byte of a number in this range equals 0. The lower 3 bytes, from least to most significant byte, determine the amount of red, green, and blue, respectively. The red, green, and blue components are each represented by a number between 0 and 255 (&HFF).

Consequently, you can specify a color as a hexadecimal number using this syntax:

&HBBGGRR&

The BB specifies the amount of blue, GG the amount of green, and RR the amount of red. Each of these fragments is a two-digit hexadecimal number from 00 to FF. The median value is 80. Thus, the following number specifies gray, which has the median amount of all three colors:

&H808080&

Setting the most significant bit to 1 changes the meaning of the color value: It no longer represents an RGB color, but an environment-wide color specified through the Windows Control Panel. The values that correspond to these system-wide colors range from &H80000000 to &H80000015.

Note   Although you can specify over 16 million different colors, not all systems are capable of displaying them accurately. For more information on how Windows represents colors, see "Working with 256 Colors" later in this chapter.

Using System Colors
When setting the colors of controls or forms in your application, you can use colors specified by the operating system instead of specific color values. If you specify system colors, when users of your application change the values of system colors on their computers, your application automatically reflects the user-specified color values.

Each system color has both a defined constant and a direct color setting. The high byte of direct color settings for system colors differs from those of normal RGB colors. For RGB colors, the high byte equals 0 whereas for system colors the high byte equals 8. The rest of the number refers to a particular system color. For example, the hexadecimal number used to represent the color of an active window caption is &H80000002&.
0
 
LVL 3

Expert Comment

by:gafoorgk
ID: 9621845
use this method to return each colors from OLE_COLOR

Private Declare Function OleTranslateColor Lib "oleaut32.dll" (ByVal lOleColor As Long, ByVal lHPalette As Long, lColorRef As Long) As Long

Private Sub GetRGB(ByVal lColor As Long, ByRef iRed As Integer, ByRef iGreen As Integer, ByRef iBlue As Integer)
    '// Translate the color if it is system color
    Call OleTranslateColor(lColor, 0&, lColor)
   
    '// Now split colors
    iRed = lColor Mod &H100
    lColor = lColor \ &H100
    iGreen = lColor Mod &H100
    lColor = lColor \ &H100
    iBlue = lColor Mod &H100
End Sub
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:neutrinohunter
ID: 9622586
can anyone figure this out cos i can't

the colour i want is &H8000000F&, which is the colour of the command button face,
ive tried converting all over the pplace but still i don't get the colour.

In the form that i can use in paint.

Or does someone know of a way to get a square root, pi and number 2 and 3 in superscript on a command button

neutrino dave

any help would be appreciated
0
 
LVL 3

Expert Comment

by:gafoorgk
ID: 9622674
what is the problem with my code. it's working perfect for the color &H8000000F&. it's first translating into a valid OLE_COLOR and then split it into Red, Green & Blue
0
 

Author Comment

by:neutrinohunter
ID: 9630139
can't anyone just tell me the RGB cos i dunno what to do with that.

Maybe an example of how to put it in text boxes would be nice

im not the most knowledgeable progarmmer as you may have guessed

neutrino dave

any help would be gratefully appreciated
0
 

Author Comment

by:neutrinohunter
ID: 9666107
plz someone

im completely baffled, and my MSDN library don't work
0
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 40 total points
ID: 9667035
why don't you simply set the color as &H8000000F (without the LAST &)

(&H is the falg that indicatged that the value is in HEX - base 16, rahter than base 10)

which is equivalent to the LONG value -2147483633


either value should give you the SAME color - set this value as the BackColor of the button.


AW
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now