如何获得NonClient上边框大小?

时间:2013-04-27 02:05:21

标签: .net vb.net winforms nonclient nonclient-area

我需要将辅助表格与其他表格的右边界对齐。

当我们在启用AERO的情况下编译并运行 COMPILED 应用程序(而不是从IDE运行它)时,会发生以下情况:

enter image description here

所以感谢 GJKH 的精彩支持:How to determine correctly the Non-Client Area Size for Aero?

...现在我可以将辅助表格对齐到主表单的右侧, 但是次要形式仍然与顶部的像素没有对齐:

enter image description here

这是我正在使用的代码:

 If Debugger.IsAttached Then
      Form2.Location = New Point(Me.Right, Me.Top)
 Else
      Form2.Location = New Point((Me.Location.X + (Me.Width + (Me.Width - Me.ClientSize.Width))), Me.Location.Y)
 End If

1 个答案:

答案 0 :(得分:1)

我把它放在Form1中的一个事件中:

    Dim frm As New Form2

    frm.Show()

    frm.SetDesktopLocation(Me.Width + Me.DesktopLocation.X, Me.DesktopLocation.Y)

和form2紧接在form1的右侧排列,其顶部排列完好。