Results 1 to 3 of 3

Thread: postion of clicked mouse

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Location
    fort wayne,IN, usa
    Posts
    12

    Post

    first thanks those answered my questions before. I learned from this board for how to
    get mouse position.
    My new question is how to write codes that
    shows mouse position whenever mouse is
    clicked only. ie., does not show whennot clicked.
    Thanks in advance.

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,176

    Post

    Place in a Form with a Timer Control:
    Code:
    Private Type POINTAPI
            x As Long
            y As Long
    End Type
    
    Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    
    Private Sub Form_Load()
        Timer1.Interval = 100
        Timer1.Enabled = True
    End Sub
    
    Private Sub Timer1_Timer()
        Dim tPOINT As POINTAPI
        If GetAsyncKeyState(vbLeftButton) Then
            Call GetCursorPos(tPOINT)
            Caption = tPOINT.x & ":" & tPOINT.y
        End If
    End Sub
    ------------------
    Aaron Young
    Analyst Programmer
    aarony@redwingsoftware.com
    adyoung@win.bright.net

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Location
    fort wayne,IN, usa
    Posts
    12

    Post

    Thanks for the eode, it works great.
    I hope you can help me a little bit further
    I also want to display positions of two
    clicked mouse. say display first clicked positon, then display second clicked positon
    in a form with first one still displayed,of
    course second as well.
    I could not figure out the "trick" doing
    it. If you know please me know
    Thanks lot in advance

    Yifei Pan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width