We help IT Professionals succeed at work.
Get Started

RichEd20 Problem: RTF Text insertion too slow

MasamuneXGP
MasamuneXGP asked
on
748 Views
Last Modified: 2012-08-13
Hello all.  I'm currently writing a code editor that I'm trying to make as close to the VB IDE as possible.  One thing it will have is colored keywords, comments, and strings.  I already have a function that goes through the text, determines what needs to be colored, and spits out the appropriate RTF code.  For my tests, I'm using 5000 lines, each with 4 color words.  The line checking goes through all of them and returns one big string containing all 5000 lines with an RTF header and tags in the appropriate places.

Here's were the bottleneck happens.  I can't seem to get this RTF text into the box without it taking WAY too long.  At first I was using the standard RichTextBox control and inserting via .SelRTF.  Later, I ditched that for vbAccelerator's RichEdit control and tried using the EM_STREAMIN method.  The gain was minimal at best.  The single line that inserts the text takes approximately 19 seconds to execute on my P4 1.7GHz machine.  This is unacceptable.

VB's IDE is able to color the same 5000 lines in the blink of an eye... There has to be a faster way.  Does anyone know how I can speed this up?
Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 20 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE