Hello,

I'm currently writing a syntax coloring algorithm using a RichTextBox to get familiar with VS2005 and Visual Basic .NET (I used to code in Visual Basic 6). Right now, using the TextChanged declaration of the RichTextBox, I recheck and recolor the entire line every time TextChanged is called. Perhaps not the best way, but it'll do for now. I'm open for suggestions on this!

Anyway, what I'm trying to deal with right now is the flickering. Typing a sentence in the RTB causes a lot of flicker while the line is being recolored. I had the idea of overriding the WndProc, and stopping any WM_PAINT messages that come in while it's repainting, but it's not going very well so far. Here's what I have right now;

Code:
    Protected Overrides Sub wndproc(ByRef m As Message)
        If (m.Msg = WM_PAINT And doNotPaint) Then
            ' ignore
        Else
            MyBase.WndProc(m)
        End If

    End Sub
doNotPaint is set to true at the begging of the recoloring, and set to false again when it's finished with this. As some might see, I'm entirely new to this WndProc thing so this code is probably rubbish. It's not even attached to the RTB control in any way.

So, could anyone give me some suggestions on this? Thanks a lot.