Syntax-Hilighting
-
Hi, I'm overriding the RichTextBox class to add syntax-highlighting functionality (HTML, XML, PHP, C). So far, I've been very successful. I have a working version with just a few bugs. The only problem that I've run in to is that when the user opens a file, the process is very slow. This is because to change the color of the text, I am using the RichTextBox's Select method to select a range of text, and then setting the field SelectionColor. If I open a file with many lines, this process takes a few seconds to complete. I notice that when I open a similar file in Visual Studio, the syntax-highlighting is instantaneous. So, I was wondering if there's a faster way to change the color of many portions of text in the RichTextBox (without selecting it first). Is this possible using Windows Messages or Win32 Functions? Thanks in advance. DigitalKing
-
Hi, I'm overriding the RichTextBox class to add syntax-highlighting functionality (HTML, XML, PHP, C). So far, I've been very successful. I have a working version with just a few bugs. The only problem that I've run in to is that when the user opens a file, the process is very slow. This is because to change the color of the text, I am using the RichTextBox's Select method to select a range of text, and then setting the field SelectionColor. If I open a file with many lines, this process takes a few seconds to complete. I notice that when I open a similar file in Visual Studio, the syntax-highlighting is instantaneous. So, I was wondering if there's a faster way to change the color of many portions of text in the RichTextBox (without selecting it first). Is this possible using Windows Messages or Win32 Functions? Thanks in advance. DigitalKing
There are no Win32 or Message functions you can use to speed this up. The problem is that you're using the worst control you can to do this. The RichTextBox does not lend itself well to syntax highlighting. Unfortunately, it's also the easiest to use without writing your own TextBox class to support this. You may want to do some research by chekcing out these[^] articles to see if you can pick up a faster technique. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome