views:

71

answers:

5

Hi, I have a image for which i have written code in MouseMove to higlight it. this is being done what i want is to when the mouse leaves image the highlights go away but i cant seem to find any event which will do that. i am working in visual basic 6.0. i have tried the mouseup and down event but they dont match my req.

Thanks

+1  A: 

There isn't an event like that in VB6 (although VB.Net has MouseLeave). You will need to do something in the MouseMove event of the form (and perhaps any container controls too).

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  ' Unhighlight the image'
End Sub

Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  ' Highlight the image'
End Sub
MarkJ
seems like the only option, i put now an array of images so a bit heavy code
jaminator
A: 

You can also put the image you want to simulate the mouseleave event inside a bigger picture. That way, when you leave the inner picture (smaller) you will hit the mousemove event of the outer picture. Also, this works if you use a frame or label instead of another picture

Claudio
A: 

You can always subclass the control. Here's an article that describes how to do it.

pm_2
A: 

There is a great little ocx control for this exact purpose written by Marco Bellinaso, a well respected author and a big contributor of good content to the VB community in his time.

The control is called the "MB MouseHelper". You can download it from devx.com at http://www.devx.com/vb2themax/CodeDownload/19735.

alt text

There are two problems with using VB's built in Mouseover event that make this control useful:

  • You have to catch all the places where the user could put the mouse when it leaves your image, like the form or another control or a nearby label
  • ANd the user can still move the mouse very quickly, jumping over any part of the window that would trigger the mouseover code that unhighlights your image
Shane
A: 

One thing to care about if you use the mouseMove event is to raise a flag when you are IN the control you want to highlight and raise another when you are OUT so as not to repeat the same action on each mouse xy change

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

' if imageIsHighlighted = true then

' Unhighlight the image'

' imageIsHighlighted = false

' end if

End Sub

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

' if imageIsHighlighted = false then

' Highlight the image'

' imageIsHighlighted = True

' end if

End Sub

Dia