Anyone Have any Idea of changing the Enabled Colour??
The default of the text being enabled is gray.Is it possible to change the Text colour when TextBox.Enabled is issued?
Please Advice... Thanks :)
Printable View
Anyone Have any Idea of changing the Enabled Colour??
The default of the text being enabled is gray.Is it possible to change the Text colour when TextBox.Enabled is issued?
Please Advice... Thanks :)
All you need to manage buttons colors is Microsoft Form2 Object library; if you cannote manage all the aspects with this, then you'll have to use images, one for the enabled status and one for the disabled one.
If all you want to do is to change the color of the text to red for example then do the following:
1) In the form Load event set Text1.ForeColor = vbRed (you could also of course do this by changing the control's font color at design time).
2) When you disable the textbox set Text1.ForeColor = vbBlack, and
3) Set it back to red when you enable it.
Gray? Do you mean change the disabled text? (rather than enabled text). If so, use the following code.Quote:
The default of the text being enabled is gray
When you load the Form, it will change the Disabled colour to blue and when you unload the Form it will change them back to the original settings.Code:Private Declare Function SetSysColors Lib "user32" (ByVal nChanges As Long, lpSysColor As Long, lpColorValues As Long) As Long
Private Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long) As Long
Const COLOR_GRAYTEXT = 17
Dim lForeColor
Private Sub Form_Load()
'Get the current colour of the Grayed text
lForeColor = GetSysColor(COLOR_GRAYTEXT)
'Change it to blue
SetSysColors 1, COLOR_GRAYTEXT, vbBlue
End Sub
Private Sub Form_Unload(Cancel As Integer)
'When the Form unloads, change the colours back to the original colours
SetSysColors 1, COLOR_GRAYTEXT, lForeColor
End Sub