IonicWind Software

IWBasic => GUI Central => Topic started by: billhsln on January 01, 2012, 02:13:21 PM

Title: Simple Calculator
Post by: billhsln on January 01, 2012, 02:13:21 PM
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
Title: Re: Simple Calculator
Post by: billhsln on January 02, 2012, 04:58:21 PM
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