Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / April 2005

Tip: Looking for answers? Try searching our database.

Double buffer a form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Martin Stenhoff - 24 Apr 2005 10:27 GMT
Is there some trick to double buffer a whole form without having to subclass
every single control on it to make each control double buffered?
I've noticed that when I resize my form the controls on it starts flicking
so much it's not even funny.

I thought I could be clever and do something like this

foreach(Control c in this.Controls){
   // Set the value of the double-buffering style bits to true.
   c.SetStyle(ControlStyles.DoubleBuffer, true);
}

but that won't work since the SetStyle method is declared as protected in
Control. (Why is it declared protected?)

Martin
Bob Powell [MVP] - 24 Apr 2005 21:51 GMT
Because all controls on a form are autonomous windows double bufferng the
form has no effect on the flickering of the controls.

The short answer is no. You may however like to look at options such as
suspending layout for a short time while resizing is going on.

Signature

Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

> Is there some trick to double buffer a whole form without having to
> subclass every single control on it to make each control double buffered?
[quoted text clipped - 12 lines]
>
> Martin
Martin Stenhoff - 25 Apr 2005 04:18 GMT
Yeah I noticed that making a form double buffered has not impact on the
child controls.

But is there a good reason for not being able to call Control.SetStyle()
from outside the
Control class?

Martin

> Because all controls on a form are autonomous windows double bufferng the
> form has no effect on the flickering of the controls.
[quoted text clipped - 18 lines]
>>
>> Martin
Bob Powell [MVP] - 25 Apr 2005 10:09 GMT
I suppose that from a class design point of view the style was made
protected so that external classes couldn't fundamentally change the drawing
system without the control providing a specific mechanism for doing so.

Those styles can have far-reaching consequences for drawing and mouse input.

Signature

Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

> Yeah I noticed that making a form double buffered has not impact on the
> child controls.
[quoted text clipped - 28 lines]
>>>
>>> Martin

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.