Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Sep 2002
    Location
    Detroit, Michigan, USA
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts

    onmousemove event catching (VBA 2000)

    This is the scenario: I have a form with numerous controls. I need to catch onmousemove events to fire up a different routine. I could do it individually and probably succeed but seems to me that it makes more sense to create a dedicated sub that would use the control as an argument and based on the control the mouse it's over, this sub would launch the second procedure (perhaps via SELECT CASE...). I am stuck with the basic structure of the sub here. I know how to do it by selecting the control and then the mousemove entry from the list but to do it from scratch.... Any help would be appreciated. Thanks in advance.

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: onmousemove event catching (VBA 2000)

    I'm not sure what exactly you are stuck with. Your sub needs to take a control argument as well as any arguments exposed by the mousemove event that you might want to use. You will then need to call your sub from the mousemove event of each control as required. Just bear in mind that your routine will get called many times!
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: onmousemove event catching (VBA 2000)

    It could look like this:

    Private Sub CheckBox1_MouseMove(ByVal Button As Integer, _
    ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    Call HandleMouseMove(Me.CheckBox1, Button, Shift, X, Y)
    End Sub

    Private Sub TextBox1_MouseMove(ByVal Button As Integer, _
    ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    Call HandleMouseMove(Me.TextBox1, Button, Shift, X, Y)
    End Sub

    Sub HandleMouseMove(ctl As Control, ByVal Button As Integer, _
    ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    Select Case ctl.Name
    Case "CheckBox1"
    ...
    Case "TextBox1"
    ...
    Case Else
    ...
    End Select
    End Sub

Posting Permissions

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