Jump to content
Sign in to follow this  

Highlighting text in Rich Text boxes (performance)

Recommended Posts

I have made a RichText-box and made a function to highlight text in certain ways (bold etc.).

So I can call this function with a text-variable and the function will higlight all instances of the text.

There is more to it, but that is the basic function.

I have a performance problem.

It seems evertime i call this (setting the text properties)

$oRP.SelStart = $markselstart - 1

$oRP.SelLength = $sizeof_searchtext

$oRP.SelFontSize = $size

to highlight, the text position is moved in the GUI to the place the text is.

And I do this for many instances of text, so the text GUI will moved up and down until it is finished.

This takes 1-4 seconds depending on how large the file is (and how many texts are to be highlighted).

I think the moving around is using ressources.

My question is -

Is there a faster way to make this highlighting?

Can I avoid the GUI moving the text-position when setting the text properties?

Here it is:


Func highlight_text_inRTbox($searchtext, $action, $size,$number)

$hitstring = $orp.text

;check if match is at the end of file. if so add a space so the highlighting can have an end point.

;if not every tekst following will be marked.



$string_in_end = StringRight($hitstring,$sizeof_searchtext)

if($sizeof_searchtext<>0 AND $string_in_end=$searchtext) Then $orp.text = $hitstring & " "

;Search the Text and put startcharacter in array

Dim $avArray[1]


Local $Counter = 0

While $counter < 1000

$Counter = $counter + 1

$result = StringInStr($hitstring, $searchtext,0,$counter)

If($result = 0) Then







;number of times to loop through (depending on size of array)


;mark the text from searchresults in array

$i = 1

While $i <= $loopingtimes

If($avArray[$i]="end") Then



$markselstart = $avarray[$i]


$oRP.SelStart = $markselstart - 1

$oRP.SelLength = $sizeof_searchtext

$oRP.SelFontSize = $size

if($action="colorredbold") Then

$oRP.SelBold = True



if($action="colorbluebold") Then

$oRP.SelBold = True



if($action="bold") Then

$oRP.SelBold = True


if($action="underline") Then

$oRP.SelUnderline = True





Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...