2013-04-27 121 views
0

我需要将辅助表单对齐到其他表单的右边框。如何获得NonClient上边框尺寸?

当我们编译(从IDE运行时,它不是)运行编译应用程序启用AERO,这是发生了什么:

enter image description here

所以感谢GJKH伟大asnwer这里:How to determine correctly the Non-Client Area Size for Aero?

...现在我可以辅助形式allign的主要形式, 但二级形式剧照右侧不对齐位的像素从到电话号码:

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

我把这个事件中Form1中:

Dim frm As New Form2 

    frm.Show() 

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

和窗口2一字排开立即向form1的权利与他们的顶部排队完美。

+0

谢谢,但只适用于调试应用程序,但不适用于从VS IDE外部手动启动编译的应用程序(如从Windows资源管理器打开“\ bin”文件夹并双击编译的应用程序),我已经测试它。 – ElektroStudios 2013-04-27 03:17:23

+0

即使在IDE之外,每次都为我工作。我在两台运行两种不同操作系统(Server 2003和Win7Pro)的不同计算机上对VS2005和VS2010进行了试用。也许更新.Net? – Richard 2013-04-27 12:03:19

+0

我有FW4.5的Win7 x64,你能告诉我你的win7和固件版本的测试结果吗? – ElektroStudios 2013-04-27 16:38:07