C# 表单绘制问题
在表单中的元素上制作透明覆盖层的最简单方法是什么?
我希望为我的表单制作一个简单的黑色(不透明度= 0.5)覆盖层,并在我的应用程序执行某些操作时激活它(例如淡入淡出屏幕)。< /strong>
谢谢。
What is the easiest way to make a transparent overlay over the elements in my form?
I wish to make a simple black (with opacity = 0.5) overlay for my form and activate it if my application is doing something (like a fadescreen).
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
控件来创建透明控件
您可以通过继承您想要使用透明面板示例的
:并在表单laded.s之后使用此:
You can create a transparent control by inherit a control you want use
a Tranparent Panel example :
And Use this after form laded.s:
最简单的方法是重写应用程序的 OnPaint 方法,并在其中添加以下行:
然后,在执行某些操作时的代码位置,将
doingSomething
设置为true
,然后调用Invalidate
。工作完成后,将doingSomething
设置为false
,并再次调用Invalidate
。The easiest is to override the application OnPaint method, and inside it add the following lines:
Then, at the place in code when your doing something, set
doingSomething
totrue
, and callInvalidate
. When the work is complete, setdoingSomething
tofalse
, and callInvalidate
again.您是否尝试过向表单添加一个覆盖整个表单区域的半透明控件?将控件停靠到整个窗体,以便它随窗体调整大小。确保它位于 Z 顺序的最上面,以便所有其他控件都呈现在它的下方。
Have you tried adding a semi-transparent control to your form that covers the entire form area? Have the control dock to the entire form, so that it resizes with the form. Make sure it is topmost in the Z-order, so that all the other controls are rendered below it.