0

When using a darker style in a Delphi application, it is very difficult to see disabled text, which is set to dark gray, and I can no way of setting this to a more usable color. I can set it in the Style Editor, but it is not used when the application is run. Has anyone else come across this behaviour, and been able to work around it?

UPDATE: When I am using a style hook, then the colour is still set to grey, even when I actually set it to a different color.

procedure TEditStyleHookColor.UpdateColors;
var
  LStyle: TCustomStyleServices;
begin
  LStyle := StyleServices;

  if Control.Enabled then
  begin
    Brush.Color := LStyle.GetStyleColor(scEdit);
    FontColor := LStyle.GetStyleFontColor(sfEditBoxTextNormal);
  end
  else
  begin
    Brush.Color := LStyle.GetStyleColor(scEditDisabled);
    FontColor   :=  clWhite; //TWinControlClass(Control).Font.Color;
  end;
end;

Example

UPDATE2

The Style editor also displays the 'wrong' font, as shown in this example.

enter image description here

mmmm
  • 2,431
  • 2
  • 35
  • 56

1 Answers1

1

I suspect that this has nothing to do with VCL styles but only with Windows/Delphi default painting of disabled controls.

Said that you have two choice as stated for example on SwissDelphiCenter:

1) place the control on a panel and disable the panel instead of the control. This way the color stays to whatever you set it.

2) make a descendent and take over the painting when it is disabled.

I've quickly tried the first and it works great.

You can also make Edit readonly, it's not the same as make it disabled, but it's usually enough and have the advantage of let you select and copy the edit content.

BigBother
  • 367
  • 2
  • 9
  • OK, I will try approach (1), I have tried making the Edit readonly, but it still looks input capable. Maybe that is a VCLStyle thing too – mmmm Jun 08 '18 at 10:20
  • @Mmarquee what do you mean exactly with "it still looks input capable"? – BigBother Jun 08 '18 at 14:05