Jump to content
EugeneK

Component color in design time

Recommended Posts

Hi

 

Say I have following simple component, in runtime it shows it as blue, but in design time in has default color, how to fix it?

unit UTestPanel;

interface

uses System.Classes, Vcl.Controls, Vcl.ExtCtrls;

type
  TBluePanel = class(TPanel)
  strict private
    FPanel: TPanel;
  public
    constructor Create(AOwner: TComponent); override;
  end;

procedure Register;

implementation

uses System.UITypes, Vcl.Forms;

constructor TBluePanel.Create(AOwner: TComponent);
begin
  inherited;
  FPanel := TPanel.Create(Self);
  FPanel.Parent := Self;
  FPanel.Align := alClient;
  FPanel.ParentBackground := False;
  FPanel.ParentColor := False;
  FPanel.Color := TColors.Blue;
end;

procedure Register;
begin
  RegisterComponents('TestObjects', [TBluePanel]);
end;

end.

 

Share this post


Link to post
1 hour ago, EugeneK said:

in runtime it shows it as blue, but in design time in has default color, how to fix it? 

It is not your code, it is the IDE's form designer which ignores the color.

Please try Tools->Options->User Interface->Form Designer and uncheck the "Enable VCL Styles" option.

Form Designer Options.png

  • Thanks 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×