Hi people
I´m new here and i´m begginning with VB .NET now
well, I have a simple problem
I wanna get the coordinates of de cursor in the picturebox, but in the following sequence
- Click in a button
- Click in a PicBox to get de coordinates
- Use the coordinates to change a TextBox
well, the subroutines usually works
Sub event
procedures
End Sub
in my case
Sub button_click
on picbox_click -----> here is my problem
get coordinates
change a value of a TextBox
End Sub
well, 2 events for one procedure
how do i do that ??? i´m desesperate !!!!!! :(
thank you!
Loading
Scott LyslePosted Dec 27, 2006, 12:06 AM
With a textbox, a picturebox, and a button, I assume the button is to enable the click event used to capture the point value. Declare two variables, on to determine whether or not the click event on the picturebox is enabled, and one to hold the current point.
System.DrawingWhen the button is clicked, set the mEnabled variable to true.
When the mouse is moved over the picture box, record the current position of the mouse into the point variable.
When the click event is fired on the picture box, if mEnabled is true, send the current point value to the text box and then disable the click event by setting mEnabled to false.
Imports
Imports System.Drawing.Drawing2D
Public
Class Form1 Private mEnabled As BooleanPrivate mPoint As Point
Private Sub btnEnable_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnEnable.Click
mEnabled = True
End Sub Private Sub picTarget_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles picTarget.Click
If mEnabled = True Then
txtPoint.Text = "Clicked at " & mPoint.X.ToString() & ", " & mPoint.Y.ToString()
mEnabled = False
End If
End Sub Private Sub picTarget_MouseMove(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles picTarget.MouseMove
mPoint.X = e.X
mPoint.Y = e.Y
End Sub
End
Class