Cameron Kloot

hi,
in my form i have a label with transparent as background with a picturebox behind it that has a streched image in it. the problem is that even though the label is transparent the picturebox doesnt draw the image behind the label, so there is only the control color of the form.
how can i make the picturebox draw the image "under" a different object
thanks




Re: Visual C# Express Edition picturebox draw everything?

nobugz

Add a new class to your project and paste the code shown below. Build. Use the new control instead, it is at the top of your toolbox. If you change the PictureBox image, you'll have to repaint the labels too.

using System;
using System.Windows.Forms;

public class TransparentLabel : Label {
public TransparentLabel() {
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, false);
}
protected override CreateParams CreateParams {
get {
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x20; // Turn on WS_EX_TRANSPARENT
return cp;
}
}
protected override void OnPaintBackground(PaintEventArgs pevent) {
// Don't paint background
}
}





Re: Visual C# Express Edition picturebox draw everything?

Cameron Kloot

thanks, that's great.
could you explain the CreateParams method please
thanks






Re: Visual C# Express Edition picturebox draw everything?

nobugz

Visit your local library and check out a copy of Charles Petzold's "Programming Windows" to learn about window style flags.





Re: Visual C# Express Edition picturebox draw everything?

paoloTheCool

Is it possible to do this with a PictureBox





Re: Visual C# Express Edition picturebox draw everything?

Cameron Kloot

from 1998 5th edition or is there a newer one






Re: Visual C# Express Edition picturebox draw everything?

nobugz

This thread talks about Label controls. Start your own thread.