Not inherrit topmost form opacity

不羁岁月 提交于 2019-12-12 05:13:15

问题


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:


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.



来源:https://stackoverflow.com/questions/30359945/not-inherrit-topmost-form-opacity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!