December 11th, 2002, 08:19 PM
[VB6] How to get the mouse cursor position in a form
I am a newbie on VB and I would like to write a PhotoHunt game in VB6.0. When player click on the image in the VB form, the program should be able to detect the coordinate of the mouse cursor with respect to the image (i.e. with the upper left coner of the image as the origin)
I know there is a function called GetCursorPos to retrieve the mouse cursor's coordinate. But that coordinates is w.r.t. the whole screen. So,
1)is there another function for getting the cursor's coordinate w.r.t. the image in the form? Or
2)are there functions for getting the form's coordinate and the image's coordinate w.r.t the whole screen?
December 11th, 2002, 09:53 PM
Im not sure what you meen by the coords of the image, but if you want to get the x and y of the mouse on a form, just put this code in Form_MouseMove
This will print the coords into the debug dialog.
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Debug.Print "x: " & X & " - y: " & Y
December 12th, 2002, 07:19 AM
oh, it seems I asked a very silly question......I was too concentrated on the mouse_click() event and didtn't notice that the coordinates I wanted was already provided by some other events.........
Now the MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) event simply solve my problem~ THX~
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.