background image

J

Jochen Stuempfig

hello,

i'd like to set an image as background on my pocket pc app.
ive seen an newsgroup entry which means that an easy way to
set an background image is to override the onPaint method.

i'tried to use the following code, but nothing happens. what
am i'm doing wrong?

greets jochen

bmp = new Bitmap(System.Reflection.Assembly.GetExecutingAssembly().

GetManifestResourceStream("my.GIF"));

Bitmap offscreenBitmap = new Bitmap(240, 300);

Graphics g = Graphics.FromImage(bmp);

g.Clear(this.BackColor);

g.DrawImage(bmp, 0, 0);
 
P

Peter Foot [MVP]

You have drawn the image to your offscreen bitmap, however you need to use
the Graphics object which is supplied in the PaintEventArgs argument in your
OnPaint method to draw the image to the form/control you are working with.
e.g.
protected override void OnPaint(PaintEventArgs e)

{

//paint the screen bitmap

Graphics g = e.Graphics;

Bitmap bmp = new
Bitmap(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResource
Stream("my.gif"));

g.DrawImage(bmp ,0, 0);

base.OnPaint (e);

}


Peter
 

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