0

Hello guys, how to track the mouse click coordinate inside the form , save it to listbox or variable. Right now i am using checkbox method which already specify the coordinate. I attach the image to illustrate my program

Attachments mouseclick.png 6.82 KB
2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by AndreRet
0

To capture the mouse co-ordinates, try something like -

'In a module add the following code...
Private Type POINTAPI
      x       As Long
      y       As Long
End Type

'Private Declare Function M_GetCursorPos Lib "user32" Alias "GetCursorPos" (lpPoint As POINTAPI) As Long

Public Sub GetCursorPos(xX As Long, xY As Long)
Dim pt      As POINTAPI
Call M_GetCursorPos(pt)

xX = pt.x
xY = pt.y
End Sub
0

To draw a line with the mouse, you can use the click events of the mouse as in -

'Enter the following code in the Form_MouseDown ( ) procedure, Form_MouseMove ( ) procedure and cmdClear_Click ( ) procedures respectively.

Private Sub cmdClear_Click()
frmDraw.Cls
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
frmDraw.CurrentX = X
frmDraw.CurrentY = Y
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Line (frmDraw.CurrentX, frmDraw.CurrentY)-(X, Y)
End If
End Sub
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.