LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Coloring slider labels

Solved!
Go to solution

Can I programatically change the colors of the labels on a slider?  So far I've tried this:

 

 





char lblArr[3][25] = { "TOP\033fg990000\033bg009900",
"MDL\033fg009900\033bg000099",
"BTM\033fg000099\033bg990000" };
for( i=0; i<3; i++ )
{
ReplaceListItem (g_C9492_pnl, C9492_SLIDER_RING, i, lblArr[i], i+1);
ReplaceListItem (g_C9492_pnl, C9492_LISTBOX, i, lblArr[i], i+1);
}



The labels in the listbox get replaced, but they're not colored. The labels in the slider get replaced, but the escape sequence are included as part of the label text (and they're not colored).



TIA for any help ...

0 Kudos
Message 1 of 2
(3,266 Views)
Solution
Accepted by topic author BA

Hi BA,

to use escape codes for listbox controls you must set them before the text they are to affect; moreover, you must pass to the escape code the actual value of the color you want to set (i.e. 0x990000), not its string representation ("990000") like you are doing now. This code works assigning colors to the element in the listbox:

 

    int    i;

    char lblArr[3][25];

    sprintf (lblArr[0], "\033fg%06X\033bg%06XTOP", 0x990000, 0x009900);
    sprintf (lblArr[1], "\033fg%06X\033bg%06XMDL", 0x009900, 0x000099);
    sprintf (lblArr[2], "\033fg%06X\033bg%06XBTM", 0x000099, 0x990000);
    for (i = 0; i < 3; i++) {
        ReplaceListItem (panelHandle, PANEL_LISTBOX, i, lblArr[i], i+1);
    }
 

Unfortunatley this is not possible on slider rings (the documentation on InsertListItems only mentions listboxes when discussing colouring escape codes).

Message Edited by Roberto Bozzolo on 02-03-2009 08:57 AM


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 2
(3,257 Views)