KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Changing the foreground and background color of an object
PRODUCT: 4D | VERSION: 2004.2 | PLATFORM: Mac & Win
Published On: July 21, 2006
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

You can change the foreground and background color of an object in a form by using the Set Color command. This command follows this syntax: SET COLOR ({*; }object; color{; altColor}). The color parameter (same as the altcolor parameter for listbox) allows you to specify the foreground and background color. It follows this formula:
Color:=–(Foreground+(256 * Background))
Below is an example code which shows how to change the foreground and background of a text variable to red and light blue respectively:

C_INTEGER(Foreground;Background)
Foreground:=Red
Background:=Light Blue
SET COLOR(*;"TextVar1";-(Foreground+(256*Background)))

Other predefined values for colors can be found at this location:
https://www.4d.com/docs/KTU/KTU00006.HTM