Colored Text

BlitzPlus Forums/BlitzPlus Programming/Colored Text

rdodson41(Posted 2003) [#1]
Is there any way to make text colored for text areas, text fields, list boxes etc.? I know you can do it for graphic text, but i can't find a way for the above things. Any help is appreciated. Thanks!

-Rich05


Seldon(Posted 2003) [#2]
The only way is to use the Windows API calls.


rdodson41(Posted 2003) [#3]
API? What is that and how do i do that?

-Rich05

PS: Can i make text areas non-editable so that they can't be typed in?


Perturbatio(Posted 2003) [#4]
SetTextAreaColor looks like a possibility.


SetTextAreaColor textarea,red,green,blue[,background]
Parameters:
textarea - A textarea gadget handle
red,green,blue - Color to apply, with color components in the range 0 to 255
background - An optional flag specifying whether the background or foreground color of the textarea should be set.


*EDIT*
EnableGadget and DisableGadget look like what you want for your second question.

(I don't have B+)


rdodson41(Posted 2003) [#5]
I see. SetTextAreaColor does work for text. But it makes the all of the text the same color regardless of its previous color, so I can't make 2 different lines 2 different colors. Do you know if this can be done?

I figured out how to make the text areas uneditable with a userlib by nullmind. It's better than DisableGadget. But thx anyway.

-Rich05


Todd(Posted 2003) [#6]
If you want to just highlight certain parts of a textarea, use the FormatTextAreaText() command and jusr give it the starting character and length of text to format. This will only work on TextAreas though, TextFields and other gadgets will have to use a Win32 API function (userlib) to change colors. Look on MSDN for some help with the Windows APIs.

In case my explanation of FormatTextAreaText() didn't make any sense, here's an example that might help get you started:
TextArea=CreateTextArea(0,0,Width,Height,Window)
SetTextAreaText(TextArea,"Line 1"+Chr(10)+"Line 2")

FormatTextAreaText(TextArea,255,0,0,0,1,6)
FormatTextAreaText(TextArea,0,0,255,0,8,6)

I haven't tried this (I don't have BlitzPlus right now) but this should work for you. Look at the TextArea section of the docs for some more on the formatting commands.


rdodson41(Posted 2003) [#7]
*Rich smacks his head so hard he falls off his seat*

I keep telling myself to look at the Command Reference slowly because what I want is probably there, but my fingers don't listen.

Thanks Todd that is just what I needed. I saw that, but I just skimmed it and missed the r,g,b. Thanks again.

-Rich05