April 18, 2024, 08:49:04 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Simple Calculator

Started by billhsln, January 01, 2012, 02:13:21 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

billhsln

I am trying to learn how to use RichEdit controls, so I started with a Simple Calculator.  Not everything works yet, but most does.  What I am looking for is how do I change the color of the Text in a RichEdit control.  I would like Positive in Black and 0 in Green or Blue and Negative numbers to be in Red.  Sounds simple, but I have not been able to figure any way to do it.

Thanks for any help.

Bill
When all else fails, get a bigger hammer.

billhsln

Found the answer to my problem:

'=========================
SUB write_rtf(text:STRING)
'=========================
DEF c:UINT
l = CONTROLCMD (w1,100,@RTGETTEXTLENGTH)
CONTROLCMD w1,100,@RTSETSELECTION,l,l
IF dval1 < 0
c = RED
ELSE
IF dval1 > 0
c = BLACK
ELSE
c = GREEN
ENDIF
ENDIF
CONTROLCMD w1,100,@RTSETSELCOLOR,c
CONTROLCMD w1,100,@RTREPLACESEL,text + CHR$(13) + CHR$(10)
CONTROLCMD w1,100,@RTSCROLL,0,1
RETURN
ENDSUB


All I needed was the CONTROLCMD w1,100,@RTSETSELCOLOR,c.

Bill
When all else fails, get a bigger hammer.