Beginupdate implementation

S

shumaker

A few form controls have a Beginupdate function that stops the control
from being painted until endupdate is called, and I'm wondering if
anyone has an idea of how to implement a function like this for other
controls. I really need a function like this for other controls
because of the flickering when I update many properties of a single
control at a time. I would like to inherite a control and add to it
beginupdate and endupdate functions.

I've read of one way to prevent redrawing of a control requires
overloading windproc, but everywhere I've read this, I've also read
that it's a bad programming practice. I think it would be a much worse
programming practice to not solve the flickering problem at all? I
mean, if there's only one solution, and a solution is necesary, then
whether or not the solution is bad practice or not isn't going to
matter?

I've tried with no success, which was suggested in the documentation:

SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);


Thanks in advance for suggestions. In the meantime I think I'm going
to try and learn managed direct3d and hope I can accomplish a more
visually acceptable user interface that updates more cleanly.
 
J

John Wood

Is this a custom control that is flickering, or are you using an existing
control (such as a listbox or a listview control) that is flickering? If
it's not your control, you're going to have difficulty removing the
flickering. I've even had to effectively rewrite the listbox to remove the
annoying flickering you get when you update items in it.

I've found that double buffering (as you mention) works well with custom
controls (derived from UserControl) to remove flickering, so long as the
message pump doesn't get a chance to spin while you're drawing.
 
S

shumaker

No, it's not a customer control, but I was considering inheriting the
control and defining a beginupdate function for that control. If I
knew how existing beginupdate works, then I could implement something
similar for the other types of controls and have a very consistent
solution.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top