Hi everyone!
I'm new to these forums, and thought I'd sign up because I need some help with C# programming. I'm just a hobbyist programmer, something I like to do in my spare time to keep myself from going insane. ;) I've been coding in C# for about a month now, so I'm not a total newb, but I'm no expert either. :)
Anyways, onto my issue.
I've found a couple of websites that show how to do control transparency, i.e. how to see what's behind the control. This works great, but I've encountered a slight problem. When moving this control on top of another transparent control, they don't get displayed properly. This is due to the way the redrawing is handled, not to mention the fact that a Paint even is only sent when the underlying control is reveled, NOT when it's being covered. In this case, I need a Paint event to be sent regardless. I've tried forcing an invalidation, but it still doesn't look right.
Here's the code I'm using in my inherited Panel class (which is the drawing surface I'm using):
Code:
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x00000020;
return cp;
}
}
protected void InvalidateEx()
{
if (Parent == null)
return;
Rectangle rc = new Rectangle(this.Location, this.Size);
Parent.Invalidate(rc, true);
}
protected override void OnPaintBackground(PaintEventArgs pevent)
{
}
Using these 3 I'm able to achieve a nice transparency effect, but only if the controls stay where they are; if they move around, this causes problems.
Basically, I'm trying to make a simple CAD program, and I want to be able to manipulate transparent objects. I'd like them to be transparent, so that if you place two objects on top of each other, you can see the bottom object through the top. If anyone has any resources on this sort of thing, I would greatly appreciate any help!