ColorSource

This property lets you tell a control where to find the colors it uses. It combines a lot of backward-compatibility options with two choices that are the ones you should use almost all the time.

Usage

oObject.ColorSource = nColorSource
nColorSource = oObject.ColorSource

Parameter

Value

Meaning

nColorSource

0

Use the colors specified in the object's various color properties (ForeColor, BackColor, etc.).

1

Use the color scheme used by the form containing the control. Because you can't control which color scheme the form uses, it's always scheme 1.

2

Use the color scheme specified in the object's ColorScheme property.

3

Use the default color scheme for this object based on the color set/color scheme system of coloring.

4

Use the 3-D settings from the Windows Control Panel. This is the right choice for dialogs.

5

Use the Window setting from the Windows Control Panel. This is the right choice for data-entry forms.


Until the last two options (nColorSource = 4 or 5) were added in VFP 5, this property could be relegated to backward compatibility. Options 1, 2 and 3 are all related to the complex color-scheme system created for FoxPro/DOS. If you need to figure this out, see Create Color Set. Option 0 seems redundant to us because, regardless of the setting of ColorSource, if you change BackColor and ForeColor from their defaults, the colors you specify are used.The really helpful choices here are 4 and 5. They tell a control or form to go to the Windows Control Panel (where the user gets to set colors for her entire system) and find out what the user has chosen and apply it here. Setting ColorSource to 4 says that the form we're on is a dialog and should use the settings for 3-D objects. ColorSource = 5 means the form is a document and should use the "window" colors. In Windows default color schemes, the main difference between those two is that dialogs have a gray background while documents have a white background. (We think it's ironic, at the least, that now that most users have color monitors, the industry trend is to use less color in applications.) Choose the right settings for your forms and they'll obey the user—very cool! This is one of the ways you let your user feel that your application is responsive.

Example

This.ColorSource = 5  && it's a data entry form

See Also

BackColor, ColorScheme, Create Color Set, ForeColor, Set Color Of Scheme, Set Color Set


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .