[英]WinForms - wrong form size
We have the following code: 我们有以下代码:
private void MainForm_Shown(object sender, EventArgs e)
{
RepositionForm();
}
private void RepositionForm()
{
Rectangle rect = Screen.PrimaryScreen.WorkingArea;
this.Width = 100;
this.Height = 117;
this.TopMost = true;
this.Left = rect.Width - this.Width - 1;
this.Top = rect.Height - this.Height - 1;
}
When we launch the app from Visual Studio - the form is shown of correct size: 100x117. 当我们从Visual Studio启动应用程序时 - 表单显示正确的大小:100x117。 However, when we launch the project by launching EXE file, the form size is 106x127.
但是,当我们通过启动EXE文件启动项目时,表单大小为106x127。
The MinimumSize, MaximumSize and Size properties are set to 100x117.
WindowsState = Minimized
ShowIcon = False
ShowInTaskbar = False
Topmost = True
MinimizeBox - False
MaximizeBox = False
FormBorderSize = FixedDialog
ControlBox = True
How can that happen that there's even a difference between how the app is launched? 怎么会发生应用程序如何推出之间的差异呢?
Thanks 谢谢
I'm going to hazard a guess that the problem is with the windows theme and/or the Desktop Window Manager not being deterministic for your OS version. 我将冒险猜测问题是Windows主题和/或桌面窗口管理器不是您的操作系统版本的确定性。
Try setting your Windows Theme to basic (Desktop->Personalise), then rerun you test. 尝试将Windows主题设置为基本(桌面 - >个性化),然后重新运行测试。 If you get different results, you know its down to Windows and not your code.
如果你得到不同的结果,你知道它到Windows而不是你的代码。
Also you you may want to check out the non-client area of the windows frame and see if that changes from OS/theme. 您也可以查看Windows框架的非客户区域,看看是否从OS /主题更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.