Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RTF highlight

Status
Not open for further replies.

hyonos

Technical User
Apr 2, 2003
46
IT
hi,
i have see in the solution, an rtf example.
now, i want put an highlight control.

for example i want write "Hallo world!" in olecontrol, and after, i want highlight "Hallo" word with yellow background and black foreground.

i have find documentation for highlight in msdn (
but how can i add in my app this highlight function ?

tnx
 
i have fund this solution:

****** BEGIN
*** by Roberto A.
******

** todo: remove previus higlight from selection

* get background color

lcolore=GETCOLOR()
p = (256 ^ 2)
i = INT(lcolore / p)
blue = i
lcolore= lcolore - (i * p)
p = (256 ^ 1)
i = INT(lcolore / p)
green = i
lcolore= lcolore - (i * p)
red = INT(lcolore)


*create color table
tabcolore= "{\colortbl ;\red"+ALLTRIM(STR(red)) + ;
"\green"+ALLTRIM(STR(green)) + ;
"\blue"+ALLTRIM(STR(blue))+";}"

testo=thisform.oleRTF.selrtF

inizioH=tabcolore+"\highlight1 "
fineH="\highlight0"

partenza=thisform.oleRTF.selstart
lunghezza=thisform.oleRTF.sellength

*seleziono un carattere in più per vedere se è uno spazio
*difatti se è uno spazio me lo toglie e io lo devo aggiungere

thisform.olertf.sellength=lunghezza+1
IF RIGHT(thisform.olertf.seltext,1)=" "
fineH=fineH+" "
ENDIF
thisform.olertf.selstart=partenza
thisform.olertf.sellength=lunghezza


IF lunghezza<=1 then
* questo passaggio lo faccio perchè se è solo 1 carattere va in errore...
* la stringa che aggiungo credo non la vada mai ad inserire nessuno...
* speriamo bene...

*testo=thisform.oleRTF.seltext

z=thisform.oleRTF.seltext
thisform.oleRTF.seltext=&quot;%%%ctemp%%%&quot;+z
testo=thisform.oleRTF.textRTF
thisform.oleRTF.selstart=partenza
thisform.oleRTF.sellength=lunghezza+11
testo=STRTRAN(testo,thisform.oleRTF.seltext, ;
inizioH+z+fineH)
thisform.oleRTF.textRTF =testo
testo=STRTRAN(thisform.oleRTF.textRTF,&quot;%%%ctemp%%%&quot;,&quot;&quot;)
thisform.oleRTF.textRTF=testo
ELSE
testo=STRTRAN(testo,thisform.oleRTF.seltext,inizioH+thisform.oleRTF.seltext+fineH)
thisform.oleRTF.selrtF =testo
ENDIF



****** END


anyone have a best solution ?
 
I thing, you can't do this another way :-(

There is class 'RichTextBoxHS' which is based on RichTextBox and has highlight function, but seems to be not free
( read more in this page )



Zhavic

---------------------------------------------------------------
In the 1960s you needed the power of two Comodore64s to get a rocket to the moon. Now you need a machine which is a vast number of times more powerful just to run the most popular GUI.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top