You must be doing it wrong =)
Ahh, but the reason your code works and mine didn't is because you aren't adding additional lines!
Apparantly there is a bug in the FormatTextAreaText command when using it after adding more text to the textarea.
What I wanted to do was after adding a line to the text, to reset all lines to normal and then highlight only the last line. I couldn't get it to work.
This is what I had to do to make it work.
Function SelectLine(textline)
For iter = 0 To TextAreaLen(ListingArea, 2)
FormatTextAreaText ListingArea, 0, 0, 0, 0, iter, 1, 2
Next
FormatTextAreaText ListingArea, 200, 50, 50, 1, textline - 1, 1, 2
End Function
Note that I had to add a For loop to unformat every line individually.
Using the zero flag doesn't work if you've just added another line to the text.
Here's a code snippet that shows the problem. It will only switch the entire text to normal if a line ISN'T added.
w=CreateWindow("", 100,100,200,500)
t=CreateTextArea(0,0,ClientWidth(w), ClientHeight(w),w)
SetTextAreaText(t,"click me click me click me")
AddTextAreaText(t,Chr$(13)+Chr$(10)+"another line")
Repeat
Select WaitEvent()
Case $803:End
Case $401
b=1-b
If Rnd(100) < 25
AddTextAreaText(t,Chr$(13)+Chr$(10)+"here's one more line")
EndIf
FormatTextAreaText(t,0,0,0,b)
End Select
Forever
|