ボタン「btn_email」のあるフォームがあります。
このボタンを押すと、新しい (非モーダル) フォームがそのボタンの下に開かれ、右揃えになります。
Dim eform As New frm_iemail
With eform
.Location = ?
.Show(Me)
End With
新しいフォームのこの (記述された) 位置を計算する最良の方法はどれですか?
この計算はどのように見えるべきですか?
モーリスの解決策の後に編集:
Dim eform As New frm_iemail
With eform
.StartPosition = FormStartPosition.Manual
.Location = New Point((Me.Left + btn_email.Left + Button1.Width), (Me.Top + btn_email.Top))
.Show(Me)
End With
アプローチ2:
Dim BorderWidth As Integer = (Me.Width - Me.ClientSize.Width) / 2
Dim TitlebarHeight As Integer = Me.Height - Me.ClientSize.Height - 2 * BorderWidth
.DesktopLocation = New Point((Me.Left + Button1.Left + Button1.Width + BorderWidth), (Me.Top + TitlebarHeight + BorderWidth + Button1.Top))
私の解決策:
Dim BorderWidth As Integer = SystemInformation.FrameBorderSize.Width
Dim TitlebarHeight As Integer = SystemInformation.CaptionHeight + BorderWidth
Dim distance As Integer = 3
Dim eform As New frm_iemail
With eform
.StartPosition = FormStartPosition.Manual
.FormBorderStyle = Windows.Forms.FormBorderStyle.None
.Location = New Point(Me.Location.X + btn_email.Location.X + btn_email.Width + BorderWidth - .Width, TitlebarHeight + Me.Location.Y + btn_email.Location.Y + btn_email.Height + distance)
.Show(Me)
End With
最終的解決:
.Location = New Point(Me.Location.X + btn_email.Right + BorderWidth - .Width, TitlebarHeight + Me.Location.Y + btn_email.Bottom + distance)