02-02-2009 12:57 PM
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 ...
Solved! Go to Solution.
02-03-2009 01:56 AM - edited 02-03-2009 01:57 AM
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).