Hello everybody,
I met a problem with FMX component.
I used a FMX frame to quickly put objects on it, add properties to change images on it and rotate them. In fact a quickly manner to build a component.
After that to reuse it I decided to put it on a bpl packaqe and to install it.
I open a fresh blank FMX project and move on the form the component (the famous frame) from the palette freshly added by the bpl package.
When I'm in design time all the propertiues are well working but when I run it:
the different properties are not working
if I put on the form 2 times the same component and run it I have a warning telling me that the Layout inside the component as the same name and refuse to continue
So I decide to simplify the problem by making a simple component like this:
Create a new fresh bpl package
Put on it a unit.pas
On this unit, I create a class deriving from TRectangle with an edit and a button
Add the code for the OnClick event to "ShowMessage" the edit content when i click on the button
compile and install the package
And the problem ? When I move this new fresh component from the palette on the form and play it the click event is not firing
But if I put the unit of the bpl package inside a new FMX project and I launch it directly by code from the form 1 in the oncreate event that works !
I have Delphi 12 Athens on Windows 11
I do not understand why it is not working
Here is the code of the unit inside the bpl :
unit uniEssai2;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
Fmx.Edit, FMX.Objects;
type
TFrame2 = class(TRectangle)
Edit: TEdit;
Button: TButton;
procedure Test(Sender: TObject);
private
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('ZEssai', [TFrame2]);
end;
{ TFrame2 }
procedure TFrame2.Test(Sender: TObject);
begin
ShowMessage(Edit.Text);
end;
constructor TFrame2.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Edit := TEdit.Create(Self);
Edit.Parent := Self;
Edit.Position.X := 8;
Edit.Position.Y := 8;
Edit.Width := 100;
Button := TButton.Create(Self);
Button.Parent := Self;
Button.Text := 'Click';
Button.Position.X := 8;
Button.Position.Y := 40;
Button.Width := 60;
Button.OnClick := Test;
end;
destructor TFrame2.Destroy;
begin
Button.Free;
Edit.Free;
inherited;
end;
end.
Do you have an idea of what is wrong?
The example is very basic I can't understand what is wrong?
Thanks for your help.