I have form with button "btn_email".
By pressing to this button I would like new (non modal) form to be opened below that button and right aligned with him.
Dim eform As New frm_iemail
With eform
.Location = ?
.Show(Me)
End With
Which is the best way to calculate this (described) position of new form?
How this calculation should look like?
EDIT after Maurice's solution:
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
Approach2:
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))
My solution:
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
Final solution:
.Location = New Point(Me.Location.X + btn_email.Right + BorderWidth - .Width, TitlebarHeight + Me.Location.Y + btn_email.Bottom + distance)