我們有以下代碼:的WinForms - 錯誤的窗體大小
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;
}
當我們推出從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
這怎麼可能發生,即應用程序的啓動方式有什麼區別?
感謝
完全刪除窗口邊框,看看你是否得到相同的行爲。 – 2013-02-28 13:19:54
你是否在VS的調試模式下啓動它? – 2013-02-28 13:20:25
@ bash.d:是的,在調試模式下 – 2013-02-28 13:28:27