Is it possable to add different collored text to a text box? - IE: Have one word be red, the next green, the next blue, etc.
You will have to use a RichTextBox for this.
Edit: More info.
Once you use this control look into the
setColor property.
Yes. There was a bug with {\rtfx..} tags that allowed users to specify how big their font was and such.
As long as you're using a rich text box, though.
afaik, theres a message you can send it to render that useless. I forget message
Quote from: Newby on May 17, 2005, 06:51 PM
Yes. There was a bug with {\rtfx..} tags that allowed users to specify how big their font was and such.
As long as you're using a rich text box, though.
Umm, what setColor property, I couldn't find a reference to it on msdn.
And what are {\rtfx..} tags?
The one in the RTB control.
Replacing the slash with the reverse should fix that exploit.
Quote from: Warrior on May 17, 2005, 06:52 PM
afaik, theres a message you can send it to render that useless. I forget message
[/b]
I'll find it later.
I found SelColor, but there is no setcolor that I can see.
Err yea, my bad.
Quote from: Newby on May 17, 2005, 06:51 PM
Yes. There was a bug with {\rtfx..} tags that allowed users to specify how big their font was and such.
As long as you're using a rich text box, though.
It's not actually a bug
Indeed it is not, its auctually RTF formatting. I'll find a link that has stuff about it later.
To simply eliminate this vulnerability to your rich text box, use EM_STREAMIN instead of EM_REPLACESEL (.SelText)
Or just...don't add it in...
txtmainchat.Text = tempstring(index) & vbCrLf & txtmainchat.Text
txtmainchat.SelStart = 0
txtmainchat.SelLength = Len(tempstring(index))
txtmainchat.SelColor = RGB(163, 163, 163)
tempstring(index) is the text to be added, txtmainchat is the chat window display
It changes all the text that color, when I just want one line that color....
How do I keep this from happing?
Isn't there a more efficient way of color formating a single line of text?
clicky (http://www.valhallalegends.com/docs/rtbox.htm)
*pretends Rabbit said nothing*
Public Sub AddChat(RTB as RichTextBox, paramArray ColorText as Variant)
With RTB
.SelStart = Len(.Text)
.SelColor = vbWhite
.SelText = "[" & Time & "] "
For i = LBound(ColorText) to UBound(ColorText) Step 2
.SelStart = Len(.Text)
.SelColor = ColorText(i)
.SelText = ColorText(i + 1)
Next i
.SelStart = Len(.Text)
.SelText = vbCrLf
.SelStart = Len(.Text)
End With
End Sub
An in-depth analysis of AddChat I wrote a while back. (http://www.quikness.com/forums/index.php?showtopic=216) Its a kinda old topic, but as long as you have something on-topic to say, their pretty lax on bumping.
Usage:
Call AddChat(frmMain.rtbChat, vbRed, "This", vbGreen, " is", vbBlue, " colorful!")
[4:38:50] This is colorful!
What's the point of setting SelStart so many times? I only set it (when using the control) at the beginning of function and I've never had any problems..
Public Sub AppendRtb(ByVal Rtb As RichTextBox, ParamArray OutputData() As Variant)
Dim I As Integer
With Rtb
.SelStart = Len(.Text)
.SelColor = QBColor(ColorWhite)
.SelText = "[" & Format$(Time$, "hh:mm:ss") & "] "
For I = 0 To UBound(OutputData) Step 2
.SelColor = QBColor(CInt(OutputData(I)))
.SelText = CStr(OutputData(I + 1))
Next I
End With
End Sub
Really? Cool. I'm just a paranoid little 8th grader, I suppose.