C
Colin McGuire
Thanks everyone for help in my previous post. Using the
"Point.op_Addition" from the previous post I have to now focus on the
real problem.
I need to manually position a new form so that its upper left hand
corner is positioned exactly in the middle of the button that was
pressed (Button1).
I can't seem to get the knack of Location() and PointToScreen() to
position the new form here. According to the help, location() is to do
with coordinates of the container and PointToScreen() for the screen
but I can't link them together properly.
Thank you again
Colin
Private Sub Button1_MouseDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles Button1.MouseDown
Dim b As Button = CType(sender, Button)
Dim f As New Form
f.StartPosition = FormStartPosition.Manual
f.FormBorderStyle = FormBorderStyle.None
f.Location = Point.op_Addition(b.PointToScreen(b.Location), _
New Size(b.Width \ 2, b.Height \ 2))
f.Size = New Size(80, 80)
f.BackColor = Color.Yellow
f.Show()
End Sub
"Point.op_Addition" from the previous post I have to now focus on the
real problem.
I need to manually position a new form so that its upper left hand
corner is positioned exactly in the middle of the button that was
pressed (Button1).
I can't seem to get the knack of Location() and PointToScreen() to
position the new form here. According to the help, location() is to do
with coordinates of the container and PointToScreen() for the screen
but I can't link them together properly.
Thank you again
Colin
Private Sub Button1_MouseDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles Button1.MouseDown
Dim b As Button = CType(sender, Button)
Dim f As New Form
f.StartPosition = FormStartPosition.Manual
f.FormBorderStyle = FormBorderStyle.None
f.Location = Point.op_Addition(b.PointToScreen(b.Location), _
New Size(b.Width \ 2, b.Height \ 2))
f.Size = New Size(80, 80)
f.BackColor = Color.Yellow
f.Show()
End Sub