C
cmac89
Dear Group,
I wonder if anyone can help me with a little VB.NET picturebox problem?
I want to let the user click on a map and where they click I want to
draw a circle. I'm using the PictureBox.MouseDown event to capture the
position of the mouse when the button is clicked. That works fine.
However when I draw a circle at that position the circle is drawn
offset by varying amounts depending on the position of the window. How
can I fix this so that the mouseposition is relative to the picturebox
control?
Craig.
---------------------------------
nx = PictureBox1.MousePosition.X
ny = PictureBox1.MousePosition.Y
Dim message As String
message = CStr(nx) + ", " + CStr(ny)
Label2.Text = (message)
Dim graphics As System.Drawing.Graphics = PictureBox1.CreateGraphics()
Dim rectangle As New
System.Drawing.Rectangle(PictureBox1.MousePosition.X,
PictureBox1.MousePosition.Y, 10, 10)
graphics.DrawEllipse(System.Drawing.Pens.Black, rectangle)
---------------------------------
I wonder if anyone can help me with a little VB.NET picturebox problem?
I want to let the user click on a map and where they click I want to
draw a circle. I'm using the PictureBox.MouseDown event to capture the
position of the mouse when the button is clicked. That works fine.
However when I draw a circle at that position the circle is drawn
offset by varying amounts depending on the position of the window. How
can I fix this so that the mouseposition is relative to the picturebox
control?
Craig.
---------------------------------
nx = PictureBox1.MousePosition.X
ny = PictureBox1.MousePosition.Y
Dim message As String
message = CStr(nx) + ", " + CStr(ny)
Label2.Text = (message)
Dim graphics As System.Drawing.Graphics = PictureBox1.CreateGraphics()
Dim rectangle As New
System.Drawing.Rectangle(PictureBox1.MousePosition.X,
PictureBox1.MousePosition.Y, 10, 10)
graphics.DrawEllipse(System.Drawing.Pens.Black, rectangle)
---------------------------------