By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,837 Members | 1,629 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,837 IT Pros & Developers. It's quick & easy.

Double BUffer

P: n/a
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.
Dec 8 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Its in C# by the way..

"Rain" wrote:
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.

Dec 8 '05 #2

P: n/a
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]
- mv*@spam.guard.caspershouse.com

"Rain" <Ra**@discussions.microsoft.com> wrote in message
news:08**********************************@microsof t.com...
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.

Dec 8 '05 #3

P: n/a
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!

"Nicholas Paldino [.NET/C# MVP]" wrote:
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]
- mv*@spam.guard.caspershouse.com

"Rain" <Ra**@discussions.microsoft.com> wrote in message
news:08**********************************@microsof t.com...
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.


Dec 9 '05 #4

P: n/a
Rain,

I'm not positive, but I would guess that it handles the painting of your
window, and any other window that is a child of your window. I can't be
sure, but I can't imagine that it would use all of these double buffers for
child windows when you already have one double buffer for the parent.

It definitely will double buffer your calls to the various methods on
the Graphics class though.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Rain" <Ra**@discussions.microsoft.com> wrote in message
news:89**********************************@microsof t.com...
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!

"Nicholas Paldino [.NET/C# MVP]" wrote:
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]
- mv*@spam.guard.caspershouse.com

"Rain" <Ra**@discussions.microsoft.com> wrote in message
news:08**********************************@microsof t.com...
> 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.


Dec 9 '05 #5

P: n/a
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

Rain wrote:
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!

"Nicholas Paldino [.NET/C# MVP]" wrote:

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]
- mv*@spam.guard.caspershouse.com

"Rain" <Ra**@discussions.microsoft.com> wrote in message
news:08**********************************@micros oft.com...
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.


Dec 10 '05 #6

P: n/a
Thanks for all your reply. You all have been veryhelpful. One more thing
though.. Does the setStyle() inlcude all the double buffering of all the
child controls, graphics, parent controls? thank you so much!

"Stefan Simek" wrote:
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

Rain wrote:
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!

"Nicholas Paldino [.NET/C# MVP]" wrote:

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]
- mv*@spam.guard.caspershouse.com

"Rain" <Ra**@discussions.microsoft.com> wrote in message
news:08**********************************@micros oft.com...

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.

Dec 12 '05 #7

P: n/a
No, it doesn't. As i've mentioned, every control is responsible for its
own drawing and parent can't affect how it's children are drawn, except
for the WS_EX_COMPOSITE flag.

Rain wrote:
Thanks for all your reply. You all have been veryhelpful. One more thing
though.. Does the setStyle() inlcude all the double buffering of all the
child controls, graphics, parent controls? thank you so much!

"Stefan Simek" wrote:

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

Rain wrote:
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!

"Nicholas Paldino [.NET/C# MVP]" wrote:

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]
- mv*@spam.guard.caspershouse.com

"Rain" <Ra**@discussions.microsoft.com> wrote in message
news:08**********************************@micr osoft.com...
>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.

Dec 13 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.