Create Firemonkey form and populate by code


I am porting over a VCL component to FMX. 99% of of the code is pure object pascal, so that works just fine – but i have a method which creates a form, poulates it with buttons and a text-box, and this quite simply doesnt work under FMX.

The whole point to creating the form manually and then populating it from code was to make sure it compiled under both VCL, LCL and FMX; and that it also displays just fine under iOS, Android and whatever platform is used.

But i keep getting “Resource /classname/ not found”, where /classname/ is whatever classname i give my temporary form class.

Something as simple as this produces the error:

TMyDialogForm = Class(TForm);

procedure TForm1.Button1Click(Sender: TObject);
LDialog: TMyDialogForm;
LDialog := TMyDialogForm.Create(application.MainForm);
LDialog.Caption := ‘Yahoo!’;

Since the error involves resource, I suspect that it is looking for some type of layout data. I have just started playing around with FMX, and i did notice that different platforms allow for different layouts. But I must admit I expected it to fall-back to the default theme, no matter what platform you target.

So — how exactly do i create a form by code, populate it and display ut using Firemonkey without running into this kind of bug? It works perfectly fine under VCL and LCL, but FMX keeps going on about resources.

Please dont tell me all forms MUST be designed?

Comments are closed.