Calculating total time of Mousemove event


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Calculating total time of Mousemove event

Hybrid View

  1. #1
    Join Date
    Mar 2005
    Posts
    49

    Calculating total time of Mousemove event

    Hi all,

    I am trying to calculate the total time the mouse pointer is over a particular command button. That is whenever i move my mouse over the command button it shuld compute the ampunt of time it stays on the command button. When i say the total time, it is the total time over multiple visits of the mouse pointer over the command button.

    Someone please help me out.

    Thanks
    Teja

  2. #2
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    I had a similar problem (get Enter/Exit events) that I solved with a dirty trick, that works as long as the button is on a form. Otherwise you have to catch the mouse event of the button container.
    Code:
    Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Command1.Tag = "" Then
            Debug.Print "Command1_MouseEnter"
            Command1.Tag = "1"  '' I'm in
            '' start date = Now
        End If
    End Sub
    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Command1.Tag = "1" Then
            Command1.Tag = ""   '' I'm out
            Debug.Print "Command1_MouseExit"
            '' total time = total time + (now - start date)
        End If
    End Sub
    I tried to use the SetCapture and ReleaseCapture API, but I had so much trouble that at the end decided for the 'easy' way.
    Marco

  3. #3
    Join Date
    Mar 2005
    Posts
    49
    Thanks mstraf...it sure helps me out.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center