我们有以下代码:
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;
}
Run Code Online (Sandbox Code Playgroud)
当我们从Visual Studio启动应用程序时 - 表单显示正确的大小:100x117.但是,当我们通过启动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
Run Code Online (Sandbox Code Playgroud)
怎么会发生应用程序如何推出之间的差异呢?
谢谢
我将冒险猜测问题在于 Windows 主题和/或桌面窗口管理器对于您的操作系统版本不是确定性的。
尝试将 Windows 主题设置为基本(桌面 -> 个性化),然后重新运行测试。如果您得到不同的结果,您就知道这是 Windows 的问题,而不是您的代码的问题。
另外,您可能想检查窗口框架的非客户区域,看看它是否与操作系统/主题发生了变化。
| 归档时间: |
|
| 查看次数: |
3323 次 |
| 最近记录: |