LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

CWGraph Plot Line Color

HI!

I want to change the line color of a CWGraph plot line.

I want to show the actual line color in a control. I am trying to use the Numeric Color control to do it.

I try to get the color, using this code:

    long int m_intColor;

    CAObjHandle m_objHandle;        // Handle for activeX control       
    GetObjHandleFromActiveXCtrl (m_intPanelID, m_intControlID, &m_objHandle);  
    CWUIControlsLib_GetCWPlotProperty (m_objHandle, NULL,  CWUIControlsLib_CWPlotLineColor, CAVT_ULONG, &m_intColor);

When I set the Numeric Color control with the value that the CWUIControlsLib_GetCWPlotProperty returns, it shows me a different color. I set the control using this command:

    SetCtrlAttribute (g_intCustomPanel, PANEL_COLORNUM, ATTR_CTRL_VAL, m_intColor);

What is it wrong in my code? What is the command that I have to use to update the color that I choose using the Numeric Color control?

Thank you in advance!

0 Kudos
Message 1 of 2
(3,048 Views)
Hi Oliveira,

The CWGraph control returns colors in BGR format instead of RGB format.  CVI reads in RGB format and thus if you tried to call the SetCtrlVal function with the BGR value, you would get incorrect results (i.e. the colors wouldn't be what you expected).

Basically what you need to do is convert between the formats. There is some example code for this found on this post.

After you convert to RGB, you can then call the SetCtrlVal function to set the Color Numeric control.

I tested this out so it should work.

Best Regards,
Jonathan N.
National Instruments
Message 2 of 2
(3,043 Views)