A forms drawing problem

O

Olie

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?
 
Z

zacks

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?

Just how is the control "docked"? Using the Anchor property?
 
Z

zacks

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.
 
O

Olie

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!
 
O

Olie

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.
 
Z

zacks

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.
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!

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

Bob Powell [MVP]

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.

--
--
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.
 

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