I am converting a large project to Firemonkey and we have some custom buttons, which does not show on the form. I have isolated the problem to a very simple project:
With the code below, on both mobile and desktop (using default new applications in Delphi XE6), creating tTestButton1 works fine, but tTestButton2 does not show on the form. How is that possible?
type
tTestButton1 = class(TButton);
tTestButton2 = class(tTestButton1);
tMainForm = class(TForm)
private
fTestButton: TButton;
public
constructor Create(aOwner: TComponent); override;
end;
constructor tMainForm .Create(aOwner: TComponent);
begin
inherited;
// fTestButton := tTestButton1.Create(Self); // this works fine (used instead of next line)
fTestButton := tTestButton2.Create(Self); //this button does not show up
fTestButton.Text := 'Test';
fTestButton.Parent := Self;
fTestButton.Visible := True;
fTestButton.Position.X := 20;
fTestButton.Position.Y := 20;
end;
TButton
!! So perhaps the workaround is that you give all of your derived buttons the same class name!! Ha ha! – BookishTButton
OK, but not a grandchild? – BookishButtonStyle
in the first example, but not in the second where TestButton1Style is not registered. – Margretmargreta