Tuesday, 20 August 2013

C# - How to Doublebuffer Controls via Bufferimage?

C# - How to Doublebuffer Controls via Bufferimage?

I've read lots of attempts to double buffer C# Controls. But they just
don't work. I'm trying to do that with a TextBox. The background is
erased, the text drawn and the flickering is visible. So I thought the
only true way of doublebuffering is to use an off-screen image. I can't
paint everything by myself so I need to make my Control / TextBox paint
itself to the image ? How do I do that ? All I have is a hdc from the
image and I have somehow to smuggle it in a PAINTSTRUCT or PaintEventArgs
right ?
// protected override void WndProc(ref Message m)
// protected override void OnPaint(PaintEventArgs e)
// ...


These double buffering techniques were NOT working:
setting DoubeBuffered via reflection
SendMessage with WM_SETREDRAW
SuspendLayout / ResumeLayout
Anyways I would like to know how to double buffer in C# with an image. And
maybe someone else needs to use this technique as well.

No comments:

Post a Comment