Search code examples
delphicomponentsfiremonkey

Firemonkey controls do not draw


I simply can't figure out what I'm doing wrong when trying to paint a control.

I've tried using TCanvas.BeginScene()/TCanvas.EndScene(), tried painting in other methods (for example main form OnPaint()).
I've tried TControl.InvalidateRect().
I get nothing.

Here's what I have in my test app:

type
  TTestControl = class(TControl)
  protected
    procedure Paint; override;
  end;

  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    fTestControl: TTestControl;
  end;

procedure TTestControl.Paint;
begin
  Canvas.Fill.Color := TColorRec.Blueviolet;
  Canvas.FillEllipse(ClipRect, AbsoluteOpacity);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  fTestControl := TTestControl.Create(Self);
  fTestControl.Parent := Self;
  fTestControl.Align  := TAlignLayout.Client;
end;

It ought to be enough, according to what's online.
Any suggestions?


Solution

  • The Canvas.Fill.Color is a TAlphaColor.

    Change the line

      Canvas.Fill.Color := TColorRec.Blueviolet;
    

    to

      Canvas.Fill.Color := TAlphaColors.Blueviolet;