Panel alpha transparency issues
I've been working for a couple of days now on a simple interface that looks nicer than the default Windows form. Please feel free to blast me if there's a better way to do this, but here's what I've found:
- Drawing alpha-transparent pngs on the form using the Bitmap class works beautifully... overlapping images is not a problem.
- However, the images aren't "clickable", so I put each image in its own "transparent" panel. This way I can tie events to the panel, like rollover, clicking, etc.
- But the panel isn't "truly" transparent. It shows the parent control backcolor/background image. This is by design, I see in the documentation and in a thread on here from last February. But I really, really, really want to be able to overlap alpha-transparent images on the form!
I've tried multiple ways to work around this, but can't seem to find a really good way to do it. For example: if all of the graphics are drawn directly on the form, then the panels can be transparent and will show the images that are correctly drawn on the form. But then, to change one of the images (like a rollover alpha value change), I have to redraw the entire form. This causes flickering. This flickering can be helped (supposedly) by setting three styles on the form:
this.SetStyle(ControlStyles.DoubleBuffer, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.UserPaint, true);
but doing so takes away the form's transparency, which gives the effect of the close, minimize, and maximize buttons being outside of the form (which I dig).
So (breathe) I feel like I'm missing something easy to fix this, but I could be wrong. I'd greatly appreciate any help that some genius out there would love to share with me.
Here's a screenshot:
<a href="http://www.thehourlys.com/temp/screenshot.png">http://www.thehourlys.com/temp/screenshot.png</a>
Here's my source:
<a href="http://www.thehourlys.com/temp/Solution1.zip">http://www.thehourlys.com/temp/Solution1.zip</a>
I'm not too proud to be really off-base here, either... if I'm missing something completely, I'll kick my feet, hang my head, but then feel really good when it looks right!
Thanks in advance for your help,
Sean

Panel alpha transparency issues
APSrinu
Thanks for the advice, Mick, I appreciate it. I'll throw some time at doing it that way and see how it goes. Enjoy your time down under...
Sean
David Wang
Basically what you need to do is create a component.
The component should have Draw and HitTest methods.
You would then call the HitTest method in the Forms mousemove and click events, and the Draw method in the forms Paint event. This is a fair amount of work but it would be worth it.
I don't fully remember it, but there is a Shape Library example at the following link, which I believe should be relatively simple to convert.
http://www.gotdotnet.com/Community/UserSamples/Details.aspx SampleGuid=920d7523-7189-4565-af1a-bc2cc42109cd
Alternatively, you could just define a region for the panel control, but this may look untidy around the edges.
dkpagan
I apologize... I just realized that I zipped up the wrong directory altogether when I posted a link to the code that I was working on. Is it Friday yet Sorry about that...