Changing Color of Boolean Indicators Programmatically

Updated Dec 12, 2017

Reported In

Software

  • LabVIEW Full
  • LabVIEW Base

Issue Details

I am using the Colors [4] property of a Boolean control or indicator, but I don't understand how to specify the True and False case colors.  When I create a constant using this property, the data type looks like a cluster of numerics.  How do I know what numeric values correspond to what colors?

Solution

The Colors [4] property actually uses an array of clusters containing two U32 numeric elements.  The two elements of each cluster are foreground and background RGB (Red, Green, Blue) colors for specific components of the control or indicator.  The first element in the cluster of the first element of the array is the Boolean False case color.  The first element in the cluster of the second element of the array is the True color case. 





To specify a color using these numeric constants, you need to know the RGB code for the color you would like to use.  Usually this code is specified by a scale from 0-255 for each color.  For example, the color red is specified by the RGB code 255, 0, 0.  To use this code, convert the RGB code numbers to hexadecimal with the form RRGGBB.  You will also need to change the format of the numeric constants in the cluster from floating point to hexadecimal.  Using the hexadecimal RGB codes, enter FF0000 (for red) and 00FF00 (for green) into the numeric constants corresponding to the case associated with each color. In this example, the False case is red and the True case is green.


A much more intuitive way to specify the color is by replacing the numeric constants in the cluster with color box constants.  To do this, delete the numeric constants in the cluster and place color box constants found on the All Functions»Numeric»Additional Numeric Constants palette of the block diagram.  After placing these constants in the cluster, specify the color you would like to use by clicking on the color box constant.

 

WAS THIS ARTICLE HELPFUL?

Not Helpful