In Firemonkey Delphi 10.3, I create a custom TFrame type to add fonctionnality :
TCustomFrame = class(TFrame);
TFrameObserver = class(TCustomFrame, IObserver)
public
procedure Update; virtual;
end;
And then my frame inherit from this class :
TfStore = class(TFrameObserver)
All was good, I save it and this morning I have the error message when I open in design time (same in exec time) :
Property fStore.Size.Width does not exist
When I ignore these error, I see that in .fmx, it remove the property :
Size.Width
Size.Height
Size.PlateformDefault
And add the :
ClientWidth
ClientHeight
If I do this, it's work :
TfStore = class(TFrame, IObserver)
Did I do something wrong ?
To reproduce :
Create a new Firemonkey Project
Add a TFrame that inherited from the test below :
type IFrameTest = interface procedure Test; end; TFrameTest = class(TFrame);
TFrameITest = class(TFrameTest, IFrameTest) procedure Test; virtual; end; TFrame1 = class(TFrameITest) private { Déclarations privées } public procedure Test; override; end;
Close and open project to have the error
Here is the code from my project:
unit Unit2;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls;
type
IFrameTest = interface
procedure Test;
end;
TFrameTest = class(TFrame);
TFrameITest = class(TFrameTest, IFrameTest)
procedure Test; virtual;
end;
TFrame2 = class(TFrameITest)
private
{ Déclarations privées }
public
procedure Test; override;
end;
implementation
{$R *.fmx}
{ TFrameITest }
procedure TFrameITest.Test;
begin
//
end;
{ TFrame2 }
procedure TFrame2.Test;
begin
inherited;
//
end;
end.
and the corresponding FMX file:
object Frame2: TFrame2
Size.Width = 320.000000000000000000
Size.Height = 240.000000000000000000
Size.PlatformDefault = False
end
TFrame is a class for which special magic is done by the IDE.
To inherit a frame from another, first create your frame with the IDE, then create the inherited frame using the IDE (Menu file / New /other... / Inheritable items / select the first frame).
I see that you need an interface. Define it in the first (ancestor) frame and add it to the class declaration.
When you have the inherited frame, you can (not mandatory, depends on what you want to do) override the virtual methods implementing the interface.
Here is the code for the base frame (TFrame3) having an interface:
And the corresponding FMX file:
Here the code for the inheriting frame (TFrame4):
And the corresponding FMX: