how to make the background in the form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Some body can help me to develop the pocket pc program, which I want the form
has background.
I try to use the source code in sample.gotdonet.com/background in form,
which is not work
the debug tell me no this background Image class
 
You can draw directly on the Form by overriding the OnPaint method and
drawing against the Graphics object.
 
I see from another post that you're using C#. A code snippet to paint a
background image is shown below. Although the OnPaint override will work
too, I've used OnPaintBackground instead.

using System.Reflection;

protected override void
OnPaintBackground(System.Windows.Forms.PaintEventArgs e)
{
base.OnPaintBackground(e);
Bitmap bmp = new
Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("DefaultNam
espace.Background.jpg"));
e.Graphics.DrawImage(bmp, 0, 0);
bmp.Dispose();
}

This code snippet assumes that your default namespace for your main project
is set to "DefaultNamespace" and that you have added a jpg named
"Background.jpg" to your project and set its "Build Action" to "Embedded
Resource". Alternatively, you can always place the background image file
onto the device and load it from there instead of embedding it into the
application.
 
Dear Sir,
thank you for your help
it is work

Tim Wilson said:
I see from another post that you're using C#. A code snippet to paint a
background image is shown below. Although the OnPaint override will work
too, I've used OnPaintBackground instead.

using System.Reflection;

protected override void
OnPaintBackground(System.Windows.Forms.PaintEventArgs e)
{
base.OnPaintBackground(e);
Bitmap bmp = new
Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("DefaultNam
espace.Background.jpg"));
e.Graphics.DrawImage(bmp, 0, 0);
bmp.Dispose();
}

This code snippet assumes that your default namespace for your main project
is set to "DefaultNamespace" and that you have added a jpg named
"Background.jpg" to your project and set its "Build Action" to "Embedded
Resource". Alternatively, you can always place the background image file
onto the device and load it from there instead of embedding it into the
application.
 

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

Back
Top