Not inherrit topmost form opacity

2019-09-18 15:34发布

If I set the opacity of the topmost form all the sub-controls are just as transparent as the form. The same goes for when using the transparencyKey, all the sub-controls have the same transparent color.

What I wish to accomplish it to have controls on the form and selectively choose which should inherit this property. Is it possible to do this even if it would require adding subforms to the form?

Any help/suggestions would be appreciated, since I couldn't find any solution that worked for me.

1条回答
乱世女痞
2楼-- · 2019-09-18 16:21

No, this is generally not possible, because it is not specific to c#, but the way Microsoft Windows works.

There are 2 ways to get proper transparency on Windows: WS_EX_LAYERED and WS_EX_NOREDIRECTIONBITMAP . Both are inaccessible using Winforms and for good reason: You will have to do any and all painting yourself, including the subcontrols.

WPF does however support this natively.

查看更多
登录 后发表回答