Hi,
1.) I'm not sure, but I think that in 2.0 it's recommended to use the
Control.DoubleBuffered property instead of SetStyles.
2.) The SetStyle or DoubleBuffered affects painting solely for the
Control it is applied to. In SWF, every single control has it's own
"surface" on which it paints itself (from the Win32 standpoint, it has
both WS_CLIPCHILDREN and WS_CLIPSIBLINGS). This is one of the reasons
why SWF is so much slower than forms created using MFC or Win32
directly. In those happy times, we used the WS_CLIPxxx flags only to
reduce flicker on dynamically resizing forms, because it drags a lot of
unnecessary overhead to control painting.
3.) There is also the (almost undocumented) WS_EX_COMPOSITE window style
in XP / 2k3, but I have a strange feeling that it's undocumented because
they don't want you to use it - the implementation seems far from
complete and causes some weird things to happen, like caption buttons
not highlighting, etc. When the flag is applied to a top-level control
(form), it causes all controls on it to paint onto the same surface,
using double buffering, in the correct order. This way you don't need to
use DoubleBuffered/SetStyles at all, but you'll certainly need a number
of hacks to get it working right, if at all possible, and even then,
you're locked to the xp/2k3 platform.
4.) What do you expect from the doublebuffering class? The only common
use for doublebuffering is control painting, and there is either the
DoubleBuffered property for 2.0, or SetStyles(ControlStyles.DoubleBuffer
| ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint) for 1.1.
I hope that what I've written makes sense, and if not, i'll try to make
myself clearer
HTH,
Stefan
Does the setStyle include the drawings(graphics painting) or only the
controls? What i really wanted to do was make a class that can manually
handle double buffering but my problem is i always do my manual double
buffering inside a OnPaint and when i will make it as a class, im having a
hard time thinking how i should do it.. Thanks!
:
Rain,
Double buffering of a custom control class can be added automatically.
You don't need to do this yourself. In the constructor of your class, call
the SetStyle method, setting the OptimizedDoubleBuffer,
AllPaintingInWmPaint, and UserPaint flags to true. This will cause your
OnPaint method to be called, and the Paint event to not be called. All of
the control painting is left to you at that point.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
Hello Gurus!
I really need this one to finish a module in my thesis. PLease please help
me. I need a double buffer class so i can call it and use it anytime i
want,
the problem is everything ive tried as a class doesnt work.. please please
help. I only need the double buffering of controls, graphics... as a
class.
Can anyone help me with this? Thank You so so much in advacne. I would
really
appreciate any help.