Click to See Complete Forum and Search --> : How to prevent a RichTextBox from repainting itself.


gregorianj
November 25th, 2002, 11:04 AM
I've created a Visual.net class called sqleditbox. It inherits from the richTextBox control. The goal is to highlight some syntaxis like comments and strings in the text. It works fine, I've just one problem. I've to use select to change the color of specific parts of the text. Evry time I'm recalculating the highlights, te control shows the process (of course very fast): it selects parts, and scrolls through the document. I've tried to prevent the control from repainting by overriding the onpaint proc, but it din't help. Finally I found a line in the help, which sais, that some controls (like TextBox) are redrawn by windows directly, and the paint event never raises. What can I do know. How to prevent a RichTextBox from repainting itself.

Amn
November 25th, 2002, 11:29 AM
I am not an expert in Visual Basic, but in WinAPi which it can address there exists a function called LockWindowUpdate. It is recommended for controls to reduce flicker. Also you might want to override the WM_ERASEBACKGROUND message handler (OnEraseBackground ?)

Good Luck !