Mouse Hover Effect in Visual Basic 6


In this lesson, I'm going to tell you about the Mouse Hover effects that you can achieve writing a few lines of code. In Visual Basic 6.0, there is no such event like mouse hover. But you can do it writing some lines of code.


The following lessons are helpful if you want to learn about events:



What is mouse hover effect?

The mouse hover technique is used in all the modern software applications as this is the key to enhancing the graphical user interface (GUI) of the software. This technique is found everywhere on the web too, in most of the websites.

Not beating around the bush, let me tell you that when you keep your mouse on an object, plainly speaking when you hover your mouse pointer over an object in the software interface, the appearance of that object changes in a particular way, like the object grows bigger, the color changes, the text is enlarged or the object becomes brighter. This is what I mean by mouse hover effects.

As I mentioned before, there is no any inbuilt event in VB6 for mouse hover which is surely a limitation of the VB6 environment whereas the later versions of Visual Basic provides the MouseHover event giving a great advantage to the programmers. However you do not have to worry too much for this as you can achieve this with only a few lines of coding in VB6.


In Visual Basic 6.0, the mouse hover effect is achieved with the help of MouseMove event.


Screenshot:




Example: When you hover on CommandButton, the button's font size increases in this example.
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Command1.FontSize = 10
End Sub

____________________________________________________
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Command1.FontSize = 8
End Sub



Download sample application: Mouse Hover