7

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. However, when we launch the project by launching EXE file, the form size is 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

4

1 回答 1

1

我会冒险猜测问题出在 Windows 主题和/或桌面窗口管理器对您的操作系统版本不是确定性的。

尝试将您的 Windows 主题设置为基本(桌面->个性化),然后重新运行测试。如果你得到不同的结果,你知道它取决于 Windows,而不是你的代码。

此外,您可能想检查 Windows 框架的非客户区,看看它是否从操作系统/主题发生变化。

于 2013-02-28T13:36:39.700 回答