Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mouse Pointer Coordinates

Status
Not open for further replies.

daveleo

Programmer
Mar 2, 2002
54
US
hello
I am learning the mousemove, mousedown and mouseup commands. The books and examples I have show very simple commands to program these events, and they all imply that the X and Y coordinates of the mouse on the form (or control) are sensed automatically. However as I move the mouse or click down, the X and Y coordintaes are always zero. I know this because I print X and Y to text boxes at the mousedown event. Also, if I draw a circle at X,Y (on mousedown), the center is always at the form's 0,0 origin.

I have changed every form property that I though would effect this.

Is their an add-in or additional control library that I need to import to get these mouse events to work?

Thanks for your time.

 
This will show you how it works. Put two labels on the form, Label1 and Label2. Place this code in the MouseMove event of the form and when you move the mouse anywhere on the form the coordinates will be displayed on the labels.

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label2.Caption = X
Label4.Caption = Y
End Sub
 
I forgot to change the name of my labels.

They should be:

Label1.Caption = X
Label2.Caption = Y


Joe

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top