I found the solution by overriding the WndProc method and
intercept the unnecessary WM_PAINT messages which cause the flicker.

From: "J. Merrill" <[EMAIL PROTECTED]>
Reply-To: "Unmoderated discussion of advanced .NET topics."
<[email protected]>
To: [email protected]
Subject: Re: [ADVANCED-DOTNET] Flicker problem in richtextbox
Date: Wed, 30 Mar 2005 21:56:22 -0500

Have you tried SendMessage(hwnd, WM_SETREDRAW, False, 0) before you start,
and the same with True instead of False when you're done?  That's the
"win32 way" to do this.

I don't know how and/or if SendMessage has had a P/Invoke wrapper built,
but it shouldn't be hard to build one if you need it.

I wonder why MS didn't build a SetRedraw method into Control...

At 07:49 AM 3/26/2005, Tony Hal wrote
>Hi,
>I am implementing syntax coloring for C# language using the richtextbox
>control.
>I handle the TextChanged event in which I need to calculate the affected
or
>changed text, tokenize the text and redraw the coloring of each token. I
got
>the tokenizer logic works fine. The updated text gets re-colored
properly.
>(This is done by setting the RichTextBox's SelectionStart,
SelectionLength,
>SelectionColor properties).
>
>The issue I am having now is flickering while the color update occurs. I
>guess this is caused by too many painting updates as each token gets
>re-colored during the TextChanged event.
>I am trying to eliminate the flickering problem by somehow disabling the
>paint update while the token recoloring occurs and invalidate the related
>region when I am really done with the recoloring. However the Paint event
>and overrriden OnPaint method of my rich text box never gets called.
>I am relatively new to winform. Maybe I am missing something here.
>If you know any advice/pointers to solve this problem, I'd really
appreciate
>it.
>
>-Tony


J. Merrill / Analytical Software Corp

===================================
This list is hosted by DevelopMentor�  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

=================================== This list is hosted by DevelopMentor� http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to