07-20-2007 10:22 AM
07-20-2007 10:38 AM
07-20-2007 11:45 AM
07-21-2007 01:19 AM
Well, the listbox actually permits the use of escape codes to set some attributes for individual list items or even part of them: this is accomplished by embedding in the string passed to the control some special labels by which you can set text foreground and background color, separate and column the elements and add some vertical line where desired. All this matter is described in the online help for InserListItem command which you should study carefully to see which possibilities are available. Just to have an example, this is the way to have a list item coloured in blue and red:
sprintf (item, "\033fg%06XThis text is written in blue \033fg%06XAnd this one in red", VAL_BLUE, VAL RED);
InsertListItem (panelHandle, PANEL_LISTBOX, -1, item, value);
Even after the introduction of the tree control, to display data when I have none or little interaction with the control I prefere using a listbox instead of a tree since that control is significantly faster in displaying data and easier to program.
07-21-2007 04:54 PM
Thanks Roberto.
Actually I want to change color of an existing label in listbox. I know I can change color when I insert new item.
Also, is there anyway to set label from index? I want to change label from index. I see GetLabelFromIndex function but I don't see SetLabelFromIndex.
07-21-2007 05:18 PM
07-21-2007 11:50 PM
01-28-2020 03:48 AM
Hello,
thanks for this efficient answer. By any luck, is there a similar procedure for elements in a table? I tried your example, but it actually prints the numbers after the escape code, instead of changing the colors...
Many thanks!
01-28-2020 04:39 PM
Table cells can be tailored calling SetTableCellAttribute; the color of text can be set with ATTR_TEXT_COLOR attribute. In order to work on a set of cells you can use SetTableCellRangeAttribute.
01-29-2020 07:35 AM
Many thanks for your fast answer. Unfortunately, I was not precise enough in my question. I would like to have, in a single cell, different colors of texts and/or background, as it seems to be possible in a listbox... Thanks again.