Well I was reworking the previous days on that old DevOrg app which consisted of a treeview and an RTF activeX controls as I decided to finally give it a filtering capability, insertion of image with rescaling and quality reduction, reworking the icon panel to look like a ribbon, etc.; and along the way, I thought of allowing it to highlight the words I typed to filter the threads and nodes of treeview. So I can see outright where those are, like this:
The trick is to work behind the scene on its RTF codes. Here is the method I created for that:
*_HighLight
Method
Lparameters cWord
LOCAL lcTable
lcTable = thisform._currenttable
SELECT(m.lcTable)
Try
* Insert
highlight color
lcRTFSource = Strtran(rtftext,'}}','}}'+Chr(13)+'{\colortbl
;\red0\green255\blue0;}')
* Add new
highlightings. Check proper, small, all caps
lcRTFSource = Strtran(m.lcRTFSource,m.cWord,'\highlight1 '+m.cWord+'\highlight0 ')
lcRTFSource = Strtran(m.lcRTFSource,Upper(m.cWord),'\highlight1 '+Upper(m.cWord)+'\highlight0 ')
lcRTFSource = Strtran(m.lcRTFSource,Lower(m.cWord),'\highlight1 '+Lower(m.cWord)+'\highlight0 ')
lcRTFSource = Strtran(m.lcRTFSource,Proper(m.cWord),'\highlight1 '+Proper(m.cWord)+'\highlight0 ')
Thisform.corTF.olerTF.textRTF=m.lcRTFSource
Catch
Thisform.corTF.olerTF.textRTF = rtftext
EndtryWhile I can instruct it with another function/method to look for any other transmutation of the word like JavaScript, JAvascript, jaVaScript, etc., I think that is an overkill for this simple need of mine.
So anyway, I am just showing here the trick on how to achieve that in case you use and RTF tool on your end and wanted to have the same on your end. Cheers!
No comments:
Post a Comment