Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mouse Over

Status
Not open for further replies.

matethreat

Technical User
Jan 5, 2004
128
0
0
AU
Hello,

I am sure the question has been covered in the past, but the search engine on the website is not allowing me to do a search right now, so I thought I would just ask the question again.

I am using a box (rectangle) over my command buttons to allow me to use colors for my buttons. What I am trying to do now is change the colour of the button when the mouse is over the box. In the mouse move event of the box I am able to change the color of the box when the mouse moves over it, but I am not able to get the color to change back when I move the mouse away from the box.

Does anyone have any ideas.

Destiny Is Not The Chances We Take, But The Descisions We Make.
 
This example uses two functions to set the color and Bold properties of a control.. to use it.. add this to the form's code window.. then for each command button that you want to effect pass the command button name in to the function fSetBold using the command button's MouseMove Event, for example to change the command button named cmdExit you'd put this in the MouseMove Event textbox:

= fSetBold("cmdExit")

to reset it back ...just call the function fResetBold from other controls that you don't want affected.. i.e from the Detail Section, or other controls surrounding the command button.. You do not have to provide the control name because the variable "strCtl" will hold the name of the last control that was set using fSetBold(), just add this to the MouseMove event of the Detail section

= fResetBold()

The variable blnSet is used to prevent flickering when moving across the command button.

===============================================
Option Compare Database
Option Explicit
Dim strCtl As String
Dim blnSet As Boolean

Function fResetBold()
If blnSet = True Then
If strCtl <> "" Then
Me(strCtl).ForeColor = 0
Me(strCtl).FontBold = False
End If
blnSet = False
End If
End Function

Function fSetBold(sI As String)
If blnSet = False Then
If strCtl <> "" And strCtl <> Null Then
Me(strCtl).ForeColor = 0
Me(strCtl).FontBold = False
End If
If sI = "cmdExit" Then
Me(sI).ForeColor = vbRed
Else
Me(sI).ForeColor = vbBlue
End If
Me(sI).FontBold = True
strCtl = sI
blnSet = True
End If
End Function
===========================================
HTH
PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top