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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to make the caption on a button change when in focus

Status
Not open for further replies.

MistyWolf

Programmer
Jan 27, 2006
7
0
0
US
I figured this out the other day when I was fiddling. This code will change the font name, font size, font font weight, and color so that the user can clearly see which button is selected when tabbing through buttons on a form. I also used it in text boxes to bold the text when the text box has focus. It worked there as well. I have not tried it with any other controls on forms yet.

This code is in a separate module called GenModule

Public Sub SetFont(strFontName As String, strFontSize As String, intFontWeight As Integer, lngFontColor As Long, conFontControl As Control)
conFontControl.FontName = strFontName
conFontControl.FontWeight = intFontWeight
conFontControl.FontSize = strFontSize
conFontControl.ForeColor = lngFontColor
End Sub

Just call the program using the below code. One for the GotFocus and one for the LostFocus

Private Sub yourSubHere_GotFocus()
' "Font Name", "Font Size", "Font Weight", "Font Color", Control
GenModule.SetFont "Tahoma", "10", 600, 16711680, Me.yourControlHere
End Sub

Private Sub yourSubHere_LostFocus()
' "Font Name", "Font Size", "Font Weight", "Font Color", Control
GenModule.SetFont "Tahoma", "8", 400, -2147483630, Me.yourControlHere
End Sub

Happy programming!
MistyWolf
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top