Hi Gregory,
[...]
In certain circumstances I wanted to change color of text in SLE
[...]
With the modified Readonly assign and the modified Enable()/Disable() methods below you can set the colors and brushes you like. If you use the code unchanged and Readonly is set to true or Disable() is called, the Textcolor will be green. All other background and text colors use the windows default colors.
CLASS MySle INHERIT SingleLineEdit
ASSIGN ReadOnly(lNewValue) CLASS MySle
SUPER:ReadOnly := lNewValue
IF SELF:ValidateControl()
IF lNewValue
SELF:Background := Brush { Color { GetSysColor (
COLOR_BTNFACE ) } }
SELF:TextColor := Color { COLORGREEN}
// This would set the default Textcolor when Readonly is set to
true
// SELF:TextColor := Color { GetSysColor ( COLOR_WINDOWTEXT ) }
ELSE
SELF:Background := Brush { Color { GetSysColor (
COLOR_WINDOW ) } }
SELF:TextColor := Color { GetSysColor ( COLOR_WINDOWTEXT ) }
ENDIF
ENDIF
RETURN lNewValue
METHOD Enable() CLASS MySle
// no need to call SUPER:Enable()
IF SELF:ValidateControl()
SELF:Setstyle ( WS_DISABLED , FALSE )
SELF:Background := Brush { Color { GetSysColor ( COLOR_WINDOW ) } } SELF:TextColor := Color { GetSysColor ( COLOR_WINDOWTEXT ) }
ENDIF
RETURN SELF
METHOD Disable() CLASS MySle
// don´t call SUPER:Disable(), because afterwards you can´t change the colors !
IF SELF:ValidateControl()
SELF:Setstyle ( WS_DISABLED , TRUE )
SELF:Background := Brush { Color { GetSysColor ( COLOR_BTNFACE ) } } SELF:TextColor := Color { COLORGREEN }
// This would set the default disabled Textcolor
// SELF:TextColor := Color { GetSysColor ( COLOR_GRAYTEXT ) }
ENDIF
RETURN SELF
btw. implement a global system where the required colors and brushes are created only once.
regards
Karl-Heinz
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (2 / 14) |
Uptime: | 13:56:50 |
Calls: | 6,645 |
Files: | 12,190 |
Messages: | 5,326,920 |