background images sooo slow

  • Thread starter Thread starter Andreas van de Sand
  • Start date Start date
A

Andreas van de Sand

Hi all,

I'm working on an application and want to use background images for forms
and controls. Using the images itself is not a problem, but when I run my
application it becomes really slow and my CPU usage goes up to 100% for a
time...
Is there a better way of setting background images?
It's just 3 images I think, all pretty small, and I already created the
objects for the images and set them to the controls at runtime so that it
uses only 3 objects and not new instances for every control.
But still...
It can't be that hard just to show a couple of images...?

Many thanks for your help...
Andreas
 
Hi Bill,

thanks for your answer.
Consider double buffering the controls that contain background images.

I already tried that, doesn't help though.
The problem is more that the controls take ages to show if I'm using
background images and transparent panels. You can watch the order they are
drawn in... would be happy if the controls would be drawn in the buffer and
then shown, so that they come up all together.

Thanks anyway... if you have another idea - I would appreciate.
Andreas
 
There is one control in the toolbox that has optimised graphics, the
PictureBox control.
You can add controls to the Picturebox via code, but you cannot drag and
drop controls onto it at design time.

If you Inherit from picturebox you can add the ability for it to act like a
container control at designtime. Placing controls on this PictureBox will
help to alleviate the slow background drawing.

Add a reference to System.Design.dll
Create a new UserControl and modify it as follows:

\\\ VB \\\
Imports System.ComponentModel

<Designer(GetType(System.Windows.Forms.Design.ScrollableControlDesigner))> _
Public Class PictureBoxContainer
Inherits System.Windows.Forms.PictureBox
'Standard code ommitted...
End Class
/////////////

\\\ C# \\\
[System.ComponentModel.Designer(typeof(System.Windows.Forms.Design.ScrollableControlDesigner))]
public class PictureBoxContainer : System.Windows.Forms.PictureBox
{
//Standard code ommitted...
}
/////////////
 
If you Inherit from picturebox you can add the ability for it to act like
a container control at designtime. Placing controls on this PictureBox
will help to alleviate the slow background drawing.

I tried this, unfortunately though it doesn't work... always get errors
about missing control property and stuff.

Thanks anyway... Andreas
 
I've never seen any errors using this method.
You can add controls to a picturebox at runtime and this just extends it to
designtime.
Is the problem related to a method you are using to query the buttons
parent?
 
Back
Top