Hi I use the code below to create an Irregular shaped form.
It works fine, but when I try to change the form while it's running parts of the
old image are still visible.
The workaround I've employed uses the AllowTransparency property.
However MSDN says that this method is "not intended to be used directly from your code".
1. Does anyone know why a part of the old image gets left behind?
2. What's the correct way to fix this?
3. What is AllowTransparency and why are we not supposed to use it.
Code:
//hack
//image change leaves bits of previous image on the form
//setting allowtransparency to false fixes this.
//why is it happening and why does this fix it?
//really amateurish coding.
this.AllowTransparency = false;
this.Visible = false;
Bitmap bmp = new Bitmap(imgpath);
//want the form to be the same size as the bitmap 
//otherwise it repeats.
this.Width = bmp.Width;
this.Height = bmp.Height;
//I want the colour of the first pixel in the image
//to be the transparent colour.
bmp.MakeTransparent(bmp.GetPixel(1,1));
this.BackgroundImage = bmp;
this.TransparencyKey = bmp.GetPixel(1,1);
this.Visible = true;