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 / Languages / C# / January 2008

Tip: Looking for answers? Try searching our database.

A forms drawing problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Olie - 18 Jan 2008 14:29 GMT
I have a window drawing problem that I hope someone may be able to
help with.

I basically have a form and a control in the form which is docked to
fill. I want to resize the form and get the docked control to resize
smoothly with the form. The problem is that the form and the control
are being painted separately. So you see the form resize and then the
docked control. Ideally I want them both to resize, paint to the
buffer and then draw to the screen.

I can not use manual painting as the control I am using I have no
access to the source code.

Does anyone have any suggestions as to how I might do this?
zacks@construction-imaging.com - 18 Jan 2008 15:01 GMT
> I have a window drawing problem that I hope someone may be able to
> help with.
[quoted text clipped - 10 lines]
>
> Does anyone have any suggestions as to how I might do this?

Just how is the control "docked"? Using the Anchor property?
Olie - 18 Jan 2008 15:24 GMT
Dock = Fill
zacks@construction-imaging.com - 18 Jan 2008 15:45 GMT
> Dock = Fill

I personally have never used the Dock property, but I just ran a test
on a simple form with one listbox control that was set to Dock Fill.
When I resize the form, the listbox resizes virtually at the same time
the form does.

I am using VS2005.
Olie - 18 Jan 2008 16:06 GMT
>I personally have never used the Dock property

How do you live without this. It is one of the most useful properties
a Control has.

> When I resize the form, the listbox resizes virtually at the same time
> the form does.

Unfortunately virtually is not quite good enough for me. I need it to
appear smooth. This is a graphics app where the appearance is
important. Also you will find that as you increase the complexity of
the control it becomes more obvious.

Thanks for your help!
JS - 18 Jan 2008 16:10 GMT
Have you tried setting the Form's DoubleBuffered property to true?
Olie - 18 Jan 2008 16:36 GMT
> Have you tried setting the Form's DoubleBuffered property to true?

Yes, thanks! I almost mentioned this in the post because I knew it
would come up. When you set double buffering it only double buffers
what is directly drawn to your form. It has no effect on the child
controls in the form.
Bob Powell [MVP] - 18 Jan 2008 22:16 GMT
For graphics applications you should always:

Set the double buffering of the control on.

Set the ControlStyles to use UserPaint.

Override OnPaintBackground so that PaintBackground does not call the base
class.

Do your painting as efficiently as possible.

Signature

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

Ramuseco Limited .NET consulting
http://www.ramuseco.com

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.

>> Have you tried setting the Form's DoubleBuffered property to true?
>
> Yes, thanks! I almost mentioned this in the post because I knew it
> would come up. When you set double buffering it only double buffers
> what is directly drawn to your form. It has no effect on the child
> controls in the form.
zacks@construction-imaging.com - 18 Jan 2008 16:37 GMT
> >I personally have never used the Dock property
>
> How do you live without this. It is one of the most useful properties
> a Control has.

I have never designed a form that had only one control on it and it
had to fill up the entire form.

> > When I resize the form, the listbox resizes virtually at the same time
> > the form does.
[quoted text clipped - 5 lines]
>
> Thanks for your help!

You might try doing the resizing yourself in the Form_Resize event.
The .NET code may have unnecessary overhead that is slowing it down.

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.