[英]Get location and size of a winform on windows desktop
I want to get location, height and width of a winform on Windows desktop after resize event fire. 我想在调整大小事件触发后获取Windows桌面上winform的位置,高度和宽度。 I try the code below: 我尝试下面的代码:
private void Form1_Resize(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
MessageBox.Show("Winform :" + Form1.Instance.DesktopBounds);
}
}
Although I resize the winform many times, the value of Form1.Instance.DesktopBounds is not change. 尽管我多次调整了winform的大小,但Form1.Instance.DesktopBounds的值没有改变。
I just wanto to get location, height and width of the winform when I resize it. 我只是想在调整大小时获取winform的位置,高度和宽度。 Could you give me some advice? 你能给我一些建议吗? And where am I wrong with the code above? 上面的代码在哪里出错?
Use RestoreBounds
instead: 使用RestoreBounds
代替:
Gets the location of the form in its normal window state. 获取窗体在其正常窗口状态下的位置。
private void Form1_Resize(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
MessageBox.Show("Winform :" + Form1.Instance.RestoreBounds);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.