4D v13.4

OBJECT SET RGB COLORS

Home

 
4D v13.4
OBJECT SET RGB COLORS

OBJECT SET RGB COLORS 


 

OBJECT SET RGB COLORS ( {* ;} object ; foregroundColor ; backgroundColor {; altBackgrndColor} ) 
Parameter Type   Description
Operator in If specified, Object is an Object Name (String) If omitted, Object is a Field or a Variable
object  Form object in Object Name (if * is specified), or Field or Variable (if * is omitted)
foregroundColor  Longint in RGB color value for Foreground color
backgroundColor  Longint in RGB color value for Background color
altBackgrndColor  Longint in RGB color value for Alternating background color

The OBJECT SET RGB COLORS command changes the foreground and background colors of the objects specified by the object parameter and the optional * parameter. When the command is applied to a List box object, an additional parameter lets you modify the alternating color of the rows.

If you specify the optional * parameter, you indicate an object name (a string) in object. If you omit the optional * parameter, you indicate a field or a variable in object. In this case, you specify a field or variable reference (field or variable objects only) instead of a string. For more information about object names, see the section Object Properties.

The optional altBackgrndColor parameter lets you set an alternate background color for even-numbered rows. This parameter is only used when the object specified is a List box or a column of the List box. When this parameter is used, the backgroundColor parameter is only used for odd-numbered rows. Using alternating colors makes lists easier to read.

If object specifies a List box object, alternating colors are used for the entire List box. If object specifies a column of the List box, only the column will use the colors set.

You indicate RGB color values in foregroundColor, backgroundColor and altBackgrndColor. An RGB value is a 4-byte Long Integer whose format (0x00RRGGBB) is described in the following table (bytes are numbered from 0 to 3, from right to left):

ByteDescription
3Must be zero if absolute RGB color
2Red component of the color (0..255)
1Green component of the color (0..255)
0Blue component of the color (0..255)

The following table shows some examples of RGB color values:

ValueDescription
0x00000000Black
0x00FF0000Bright Red
0x0000FF00Bright Green
0x000000FFBright Blue
0x007F7F7FGray
0x00FFFF00Bright Yellow
0x00FF7F7FRed Pastel
0x00FFFFFFWhite

Alternatively, you can specify one of the “system” colors used by 4D for drawing objects whose colors are set automatically. The following predefined constants are provided by 4D:

Constant Type Value
Background color Longint -2
Dark shadow color Longint -3
Disable highlight item color Longint -11
Foreground color Longint -1
Highlight menu background color Longint -9
Highlight menu text color Longint -10
Highlight text background color Longint -7
Highlight text color Longint -8
Light shadow color Longint -4


These colors (on a standard system) are shown here:

WARNING: These automatic colors are system dependent. If you change your system colors, 4D will adjust its automatic colors accordingly. Use the automatic color values for setting objects to the system colors, not for setting them to the example colors shown above.

This form contains the two non-enterable variables vsColorValue and vsColor as well as the three thermometers: thRed, thGreen, and thBlue.

Here are the methods for these objects:

  ` vsColorValue non-enterable Object Method
 Case of
    :(Form event=On Load)
       vsColorValue:="0x00000000"
 End case
  ` vsColor non-enterable variable Object Method
 Case of
    :(Form event=On Load)
       vsColor:=""
       OBJECT SET RGB COLORS(vsColor;0x00FFFFFF;0x0000)
 End case
 
  ` thRed Thermometer Object Method
 CLICK IN COLOR THERMOMETER
 
  ` thGreen Thermometer Object Method
 CLICK IN COLOR THERMOMETER
 
  ` thBlue Thermometer Object Method
 CLICK IN COLOR THERMOMETER

The project method called by the three thermometers is:

  ` CLICK IN COLOR THERMOMETER Project Method
 OBJECT SET RGB COLORS(vsColor;0x00FFFFFF;(thRed<<16)+(thGreen<<8)+thBlue)
 vsColorValue:=String((thRed<<16)+(thGreen<<8)+thBlue;"&x")
 If(thRed=0)
    vsColorValue:=Substring(vsColorValue;1;2)+"0000"+Substring(vsColorValue;3)
 End if

Note the use of the Bitwise Operators for calculating the color value from the thermometer values.

When executed, the form looks like this:

Changing to transparent background with a light font color:

 OBJECT SET RGB COLORS(*;"myVar";Light shadow color;Background color none)

 
PROPERTIES 

Product: 4D
Theme: Object Properties
Number: 628

 
INDEX

Alphabetical list of commands

 
HISTORY 

Modified: 4D 2004
Renamed: 4D v12

 
SEE ALSO 

Bitwise Operators
OBJECT GET RGB COLORS
OBJECT SET COLOR
Select RGB Color