MISSION AND VISION 2012


On this Blog you can gain and collect some ideas, information about different kinds of topics about computer, tutorial and tips that can be applied. You can share your ideas too thru posting comment and feedback to said topic.

Thank You :)

Note : If the Link(s) doesn't work/broken please Comment.

(If this site helps you, please Comment and click the link to say Thanks)
Please Click here to Say Thank You :)



Friday, February 19, 2010

Implementing mouse-over effects on VB6 forms

Takeaway: Mouse-over effects can be an effective way to improve the visual appearance of your VB programs. Learn how to create mouse-over effects on your forms.


If you spend much time browsing the Web, you'll notice that some Web pages feature mouse-over effects. These effects change the appearance of a screen element when a user passes the mouse cursor over the element without clicking on it. When the user moves the mouse cursor, the element goes back to its original appearance.

Mouse-over effects can be an effective way to improve the visual appearance of your programs. In order to create mouse-over effects in VB6, you'll need to use the MouseMove event, which fires whenever the mouse cursor moves over a screen element. Here's what to do:

  1. In the MouseMove event procedure for the control for which you're creating the mouse-over effect, put code that changes the font, color, or other aspects of the control's appearance.
  2. In the MouseMove event procedure for the control's container (which is usually the form), place code that changes the control back to its normal appearance.

You may also want to save the control's default appearance when the form loads. This allows you to change its default appearance in the VB form editor without worrying about changing your code.

Here's an example that implements a mouse-over effect for a command button. In the form, at the module level, declare two variables to hold the control's default color and font size:

Private OrigColorAs Long
Private OrigSize As Integer

In the form's Load event procedure, load these variables with the control properties:

Private Sub Form_Load()
OrigColor = Command1.BackColor
OrigSize = Command1.Font.Size
End Sub

In the command button's MouseMove event procedure, change its appearance to the "over" state:

Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, _
X As Single, Y As Single)
Command1.BackColor = vbRed
Command1.Font.Size = 14
End Sub

Finally, in the form's MouseMove event procedure, change the variables back to the default values:

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, _
Y As Single)
Command1.Font.Size = OrigSize
Command1.BackColor = OrigColor
End Sub



No comments:

Post a Comment