简体   繁体   English

不继承最高形式的不透明度

[英]Not inherrit topmost form opacity

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. 任何帮助/建议都将不胜感激,因为我找不到适合我的解决方案。

No, this is generally not possible, because it is not specific to c#, but the way Microsoft Windows works. 不,这通常是不可能的,因为它不是特定于c#的,而是Microsoft Windows的工作方式。

There are 2 ways to get proper transparency on Windows: WS_EX_LAYERED and WS_EX_NOREDIRECTIONBITMAP . 有两种方法可以在Windows上获得适当的透明度:WS_EX_LAYERED和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. 两者都无法使用Winforms进行访问,并且有充分的理由:您将必须自己进行任何绘画,包括子控件。

WPF does however support this natively. 但是WPF确实支持此功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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