onmousemove and restoring after no more mousemove

ShovelinFishHeads

Registered User.
Local time
Today, 14:49
Joined
Aug 4, 2016
Messages
57
I have a bound form that I am working to make function like a menu (you know the old style where the items "highlight" as you move a mouse over them?)

So I am using this to make a textbox "change" while the mouse is over it:

Private Sub View_Activity_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

Me.[View Activity].ForeColor = vbWhite
Me.[View Activity].BackColor = vbBlack

End Sub

Then I want to use:

Me.[View Activity].ForeColor = vbBlack
Me.[View Activity].BackColor = vbWhite

as soon as the user moves the mouse off of the textbox (so the textbox goes back to it's normal state)

What event must be used to do this? Isn't there a "mouseover" event to do this?
 
You could set a timer on mouse move, like . . .
Code:
Private Sub Text0_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    With Me.Text0
[COLOR="Green"]        'less flicker if you don't set these for EVERY mouse move[/COLOR]
        If .ForeColor <> vbWhite Then .ForeColor = vbWhite
        If .BackColor <> vbBlack Then .BackColor = vbBlack
    End With
    Me.TimerInterval = 250  [COLOR="Green"]'start timer[/COLOR]
End Sub
...and then set the colors back when the timer fires...
Code:
Private Sub Form_Timer()
   Me.TimerInterval = 0
   Me.Text0.ForeColor = vbBlack
   Me.Text0.BackColor = vbWhite
End Sub
 
I have a very simple routine. Put this code in your form

Code:
Option Compare Database
Option Explicit
 
Dim overctrl As Control
  
Private Function mouseover(Optional ctrl As Control)
     If Not overctrl Is Nothing Then 'previous control exists, so set backcolor back to default
 
         overctrl.BackColor = vbWhite
         
     End If
    If Not ctrl Is Nothing Then 'a control
 
        ctrl.BackColor = vbRed
        Set overctrl = ctrl
 
    Else
 
        Set overctrl = Nothing
 
    End If
    
End Function
  
 'add sections as required
Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
 
     mouseover
    
End Sub
  
 'add controls as required
 Private Sub Text0_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
    mouseover Text0
    
End Sub
 
Private Sub Text2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  
     mouseover Text2
    
End Sub
 
Assuming that these buttons are on the Detail Section of the Form, you can use the Detail_MouseMove event to 'reset' the buttons' formatting.

Linq ;0)>
 
Thanks everyone for contributing to this thread.

For some reason I thought this would be a lot simpler. Now I see that it's not simple at all.

missinglinq:

You're referring to the mousemove event for the detail section? I could not get that to work.
 
You're referring to the mousemove event for the detail section? I could not get that to work.

Your code for the [View Activity] control would be

Code:
Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  Me.[View Activity].ForeColor = vbBlack
  Me.[View Activity].BackColor = vbWhite
End Sub
You'd then have to include code, in this same event, to reset the formatting for any other controls you were changing when hovered over.

As for the 'simplicity,' you're trying to make a database app behave like a website, and doing things an app is not designed to do generally does take a little work.

Linq ;0)>
 
I would really like to put more time into working on this but the reality is that the CRM work I am doing in Access is just about the only thing that is holding up the launching of my new business. Which means that time I spend on this is costing me money (unfortunately).

So, maybe I will come back to this at a later time but for now I have to concentrate on more important parts of my CRM project. Menus that are 'fancy' just aren't that important right now.
 

Users who are viewing this thread

Back
Top Bottom