-1

I created a test component

unit Control1;

interface

uses
  System.SysUtils, System.Classes, FMX.Types, FMX.Controls;

type
  TTestComp = class(TControl)
  private
    i: integer;
  protected
    procedure Paint; override;
  public
    constructor Create(AOwner: TComponent); override;
  published
    property Width;
    property Height;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Test', [TTestComp]);
end;

{ TTestComp }

constructor TTestComp.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  i := 0;
end;

procedure TTestComp.Paint;
begin
  inherited;
  inc(i);
  canvas.BeginScene;
  canvas.Fill.Color := $FF000000;
  canvas.FillRect(localrect, 0, 0, [], 1);
  canvas.Fill.Color := $FFFFFFFF;
  canvas.FillText(localrect, IntToStr(i), false, 1, [], TTextAlign.Center);
  canvas.EndScene;
end;

end.

Here is the problem:

  1. Component is drawing in top-left corner
  2. Too much paint method calls when resizing form.

Just resized form

Just resized form.

I have a lot of components, built according to this principle. And when I change the size of the form, they begin to lag (Low FPS).

Standard components (TButton and etc.) work fine

1 Answers1

0

1.Component is drawing in top-left corner

Your component is drawing exactly where it is placed (Position property). If you don't assign any values to Position.X and Position.Y the default values 0 is used for both.

2.Too much paint method calls when resizing form.

When you resize the form all components are re-painted, also f.ex. buttons. In a test with 81 of your controls I did not realize any lagging (but I assume your actual controls do some more painting than this example control).

Tom Brunberg
  • 20,312
  • 8
  • 37
  • 54