4D v16.3

OBJECT SET COLOR

Home

 
4D v16.3
OBJECT SET COLOR

OBJECT SET COLOR 


 

OBJECT SET COLOR ( {* ;} object ; color {; altColor} )  
Parameter Type   Description
Operator in If specified, Object is an Object Name (String) If omitted, Object is a Field or a Variable
object  Field, Variable in Object Name (if * is specified), or Field or Variable (if * is omitted)
color  Longint in New colors for the object
altColor  Longint in Alternating colors for a list box

The OBJECT SET COLOR command sets the foreground and background colors of the form objects specified by object. If object is a list box, an additional parameter is used to set the foreground and background colors for even-numbered rows (alternating colors).

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 Object Properties section.

The color parameter specifies both foreground and background colors. The color is calculated as:

Color:=-(Foreground+(256 * Background))

where Foreground and Background are color numbers (from 0 to 255) within the color palette.

Color is always a negative number. For example, if the foreground color is to be 20 and the background color is to be 10, then color is – (20 + (256 * 10)) or –2580.

altColor is used to specify an alternative background color for the even-numbered rows of a list box or a list box column. In altColor, you must pass only the "background" part of the color formula, i.e. AltColor:=-(256 * Background).
When this parameter is passed, the color parameter will be applied only to odd-numbered rows. Using alternating colors makes lists easier to read. If object specifies the list box object, alternating colors are used throughout the entire list box. If object specifies a column, only the column will use the colors set.

Note: You can see the color palette in the Form Editor’s Property List window.

The numbers of the commonly used colors are provided by the following predefined constants, located in the “Colors” theme:

Constant Type Value
Black Longint 15
Blue Longint 6
Brown Longint 13
Dark blue Longint 5
Dark brown Longint 10
Dark green Longint 9
Dark grey Longint 11
Green Longint 8
Grey Longint 14
Light blue Longint 7
Light grey Longint 12
Orange Longint 2
Purple Longint 4
Red Longint 3
White Longint 0
Yellow Longint 1

Note: While OBJECT SET COLOR works with indexed colors within the default 4D color palette, the OBJECT SET RGB COLORS command allows you to work with any RGB color. To reestablish automatic colors for an object, use the OBJECT SET RGB COLORS command with the Default foreground color and Default background color constants.

The following example sets the color of the text area shown below in the form editor:

After executing the following statement:

 OBJECT SET COLOR(*;"Mytext";-(Yellow+(256*Red)))

... the area appears as follows:

You want to set an alternating background color for a column in the list box. You can write: 

 OBJECT SET COLOR(*;"countryCol";-(Dark blue+(256*Red));-(256*Orange))



See also 

OBJECT SET RGB COLORS
Programming Notes

 
PROPERTIES 

Product: 4D
Theme: Objects (Forms)
Number: 271

 
HISTORY 

Modified: 4D 2004
Renamed: 4D v12

 
ARTICLE USAGE

4D Language Reference ( 4D v16)
4D Language Reference ( 4D v16.1)
4D Language Reference ( 4D v16.2)
4D Language Reference ( 4D v16.3)