|
-
Nov 12th, 2007, 05:31 AM
#1
Thread Starter
Member
[2005] Override WndProc
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.
-
Nov 12th, 2007, 06:51 AM
#2
Re: [2005] Override WndProc
I'm not sure whether that theory will hold or not, but you need to override the RTB's WndProc method if it's to have a chance. That means defining your own class that inherits RichTextBox, overriding WndProc, then placing an instance of that class on your form instead of a regular RTB.
-
Nov 12th, 2007, 07:15 AM
#3
Thread Starter
Member
Re: [2005] Override WndProc
Sounds good, but how would I do that? I have no idea how to create classes that inherit user controls.
-
Nov 12th, 2007, 07:31 AM
#4
Re: [2005] Override WndProc
There are no UserControls involved. You inherit the RichTextBox class the same way you inherit any other class. You declare a class and you add an Inherits line.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|