简体   繁体   中英

Semi-transparent panel background

I have a panel which sits on top of a control that renders video. I have controls (buttons, etc), on that panel which I want to be fully opaque. Now, creating a transparent panel background is doable, by overriding the CreateParams property. However, how to I make a panel with a semi-transparent (~50% opacity) background, while keeping the buttons fully opaque?

I am using .NET 2.0.

In the end it turned out that this isn't possible really, setting transparency on a panel is pretty rubbish in WinForms.

The workaround I used was to render the controls manually onto the given surface, and alter the alpha values appropriately.

You could use two panels, one placed within the other. The outer panel has no background, and hosts the inner panel and the controls, and the inner panel, whose Z-Index places it behind the controls, provides the semi-transparent background.

I'll admit that I'm suggesting this without actually verifying that this will work...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM