Special Effect annoying reset delay

S

Silvio

Hello, I am working on creating special effects (raised) when the mouse move
over a control. I am able to create such effect and remove it when moving
away, however the problem I am having is that if move the control next to
each other (no space in between the control) the special effect engage but do
not resent once I move over the next control on the right or left (once a
move the mouse around will slowly reset). For clarity I am replicating
OnMouseMove effects like the own you can observe in Internet Explorer menu
bar.

This is what I have for the control:
Private Sub imgRefresh_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Me.imgRefresh.SpecialEffect = 1
End Sub

This is what I have in the form header OnMouseMove to remove the special
effect:
Private Sub FormHeader_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
If Me.imgRefresh.SpecialEffect = 1 Then
Me.imgRefresh.SpecialEffect = 0
End If
End Sub

Any Idea how I can handle this annoying reset delay?
Thank you,
Silvio
 
B

Beetle

Reset it in the mouse move event of the other control.

Private Sub imgRefresh_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Me.imgRefresh.SpecialEffect = 1
Me.imgOther.SpecialEffect = 0
End Sub


Private Sub imgOther_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Me.imgRefresh.SpecialEffect = 0
Me.imgOther.SpecialEffect = 1
End Sub
 
D

Dirk Goldgar

Silvio said:
Hello, I am working on creating special effects (raised) when the mouse
move
over a control. I am able to create such effect and remove it when moving
away, however the problem I am having is that if move the control next to
each other (no space in between the control) the special effect engage but
do
not resent once I move over the next control on the right or left (once a
move the mouse around will slowly reset). For clarity I am replicating
OnMouseMove effects like the own you can observe in Internet Explorer menu
bar.

This is what I have for the control:
Private Sub imgRefresh_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Me.imgRefresh.SpecialEffect = 1
End Sub

This is what I have in the form header OnMouseMove to remove the special
effect:
Private Sub FormHeader_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
If Me.imgRefresh.SpecialEffect = 1 Then
Me.imgRefresh.SpecialEffect = 0
End If
End Sub

Any Idea how I can handle this annoying reset delay?


When I last did this, a few years ago, I found that it wasn't enough to use
the MouseMove event of the surrounding section, when the controls were close
together. That event may not always get a chance to fire when moving
quickly from one control to its neighbor.

What I would do is reset all the controls' SpecialEffect properties in the
MouseMove events of each of the controls, as well as the surrounding
section. I'd define a Sub for the purpose, so I could use one line of code
to do it in each event. So the code might look like this:

'----- start of example code -----
Private Sub ResetControlEffects()

With Me.imgRefresh
If .SpecialEffect <> 0 Then .SpecialEffect = 0
End With

With Me.imgOther
If .SpecialEffect <> 0 Then .SpecialEffect = 0
End With

' ... and so on ...

End Sub


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

' Reset special effects for all relevant controls.
ResetControlEffects

Me.imgRefresh.SpecialEffect = 1

End Sub



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

' Reset special effects for all relevant controls.
ResetControlEffects

End Sub
'----- end of example code -----
 
M

Marshall Barton

Silvio said:
Hello, I am working on creating special effects (raised) when the mouse move
over a control. I am able to create such effect and remove it when moving
away, however the problem I am having is that if move the control next to
each other (no space in between the control) the special effect engage but do
not resent once I move over the next control on the right or left (once a
move the mouse around will slowly reset). For clarity I am replicating
OnMouseMove effects like the own you can observe in Internet Explorer menu
bar.


The way I do that kind of thing is to create the function:

Dim strPrevious As String

Public Function MouseHandler(strControl As String)
On Error Resume Next

If strPrevious <> strControl Then
Me(strPrevious).SpecialEffect = 2
Me(strControl).SpecialEffect = 1
strPrevious = strControl
End If
End Function

Then you can set the OnMouseMove event property of each
control to:
=MouseHandler("name of the control")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top