LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Text box colors within the text

Hello all,
I know this is discussed fairly regularly, but I can't seem to find the info
right now [my official excuse is that I have the flu]: how do you change the
color of the text within a text box using control characters ?
Can you do that with string controls and text controls as well ?
Thanks
--
Guillaume Dargaud
http://www.gdargaud.net/


0 Kudos
Message 1 of 5
(3,978 Views)
Unfortunately you cannot change the colour of part of the text in a textbox: this type of control, like text messages and string controls, accepts only a single colour for the whole text and cannot handle escape codes, which on the other hand is well managed by listboxes: here an example


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 5
(3,964 Views)
> Unfortunately you cannot change the colour of part of the text in a
> textbox: this type
> of control, like text messages and string controls, accepts only a single
> colour for the
> whole text and cannot handle escape codes, which on the other hand is well
> managed by listboxes:

Thanks for the answer. Yeah, I remember using that. Very unwieldy when all
you want to do is dump a long message. I wish there was a way to do this in
some simple text control:
SetCtrlVal(Panel, Control, "This is the first line\n"
"\033fgff0000This text starts red \033fg00ff00and continues green\n"
"And this concludes.");

The way I see it, there's no way to do the above. In a listbox, everything
ends up on the same line. In a string/text box, colors are ignored.

I remember discussions long ago about how to display rtf code... Did
anything ever came out of it ?
--
Guillaume Dargaud
http://www.gdargaud.net/


0 Kudos
Message 3 of 5
(3,951 Views)
Well, I can do the following to break the multiple lines:

ClearListCtrl (Eval, EVAL_HELP);
Pos=strtok(PostfixEval_Help(), "\n");
while (Pos!=NULL) {
InsertListItem (Eval, EVAL_HELP, -1, Pos, 0);
Pos = strtok (NULL, "\n");
}

But that still leaves a whole bunch of issues:
- there is no line/word wrap
- there is no horizontal scroll bar (combined with the above, makes it
impossible to see the end of long lines)
- you cannot copy/paste from any of it
- there's a frame around the whole thing (which may or may not be wanted)
--
Guillaume Dargaud
http://www.gdargaud.net/


0 Kudos
Message 4 of 5
(3,949 Views)

I agree with all the list you give, with the only exception of the last item: if you use a classic-style list box you can paint the surrounding frame in transparent even if the panel has the "Use Windows visual style for controls" attribute set.

 



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 5 of 5
(3,946 Views)