background image

  • Thread starter Thread starter Jochen Stuempfig
  • Start date Start date
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);
 
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
 
Back
Top