Access to a write-only property in Delphi

  

I have a difficulty to access the colours used in gradients, for example for a TRectangle in firemonkey. The gradient properties (color and color1) are defined write-only, but it would be necessary to read their value.
What is the correct way to access the read values of these properties?
unit Unit1;

interface

uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Objects;

type
TForm1 = class(TForm)
Rectangle: TRectangle;
procedure FormCreate(Sender: TObject);
private
{ private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.fmx}

procedure TForm1.FormCreate(Sender: TObject);
var
ColorGradient1: TAlphaColor;
begin

// Error [dcc32 Error]: E2130 Cannot read a write-only property
ColorGradient1 := Rectangle.Fill.Gradient.Color1;

end;

end.

Comments are closed.