C# - 制作形式半透明的同时移动 [英] C# - Make form semi-transparent while moving
问题描述
有什么办法使窗体半透明而被移动,然后当它不再被移动变为不透明?我已经试过,没有运气。
我被困在 Form_Move
事件,任何帮助?
Is there any way to make the form semi-transparent while it is being moved and then become opaque when it's not being moved anymore? I have tried the Form_Move
event with no luck.
I'm stuck, any help?
推荐答案
究其原因,形式负载为半透明是因为表格必须移动到起始位置,从而引发Move事件。您可以通过基础不透明度是否设置,在窗体是否完全加载克服。
The reason the form loads as semi-transparent is because the form has to be moved into the starting position, which triggers the Move event. You can overcome that by basing whether the opacity is set, on whether the form has fully loaded.
表格后,ResizeEnd事件触发已经完成移动,所以这样的事情应工作:
The ResizeEnd event fires after a form has finished moving, so something like this should work:
bool canMove = false;
private void Form1_Load(object sender, EventArgs e)
{
canMove = true;
}
private void Form1_Move(object sender, EventArgs e)
{
if (canMove)
{
this.Opacity = 0.5;
}
}
private void Form1_ResizeEnd(object sender, EventArgs e)
{
this.Opacity = 1;
}
这篇关于C# - 制作形式半透明的同时移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!