Example Code

Change Color Numeric Control Programmatically

Code and Documents

Attachment

Overview

This is a simple example where the color of a color numeric control changes according to the numeric value on a dial.

 

Description

This example makes use of an EVENT_COMMIT callback on a dial. We use the GetCtrlVal function to determine what value is stored in the dial. Using this and a simple 'if' statement, we use the MakeColor function to dictate what color will be displayed on the color numeric control. See the following resources for additional information:

 

http://zone.ni.com/reference/en-XX/help/370051T-01/cvi/uiref/cvicolor_numeric_control_overview/

http://zone.ni.com/reference/en-XX/help/370051V-01/cvi/uiref/cvimakecolor/

http://zone.ni.com/reference/en-XX/help/370051V-01/cvi/uiref/cvisetctrlval/

 

Steps to Implement or Execute Code

  1. Unzip the NumericColorChange folder
  2. Open the NumericColorChange.prj project
  3. From within the CVI workspace, open the NumericColorChange.c file and the NumericColorChange.uir file
  4. Click the run button
  5. Scroll up and down on the dial control to view the color change.

 

Requirements

Software: CVI 2012 (or later)

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

 

 

Kelsey W.
National Instruments
Applications Engineer

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.