Reputation: 37916
I'm stuck. How to get an active form in FireMonkey Android application?
I have only a TComponent
placed on this form, but it seems like it doesn't contain a reference to the root element.
I dynamically create a control (TToolBar
) and want to add it to the top of the active form, when component is placed on it. The problem is:
ToolBar := TToolBar.Create(Application);
ToolBar.Align := TAlignLayout.alTop;
ToolBar.Parent := ?; // I don't know what parent to specify for this control
May be I should instantiate a new form and place the control on it?
Upvotes: 1
Views: 1276
Reputation: 37916
The right solution:
ToolBar.Parent := Application.MainForm;(docs)
This will work, but you will be unable to add childrens to the ToolBar
:
if Application.HasParent then(docs)
ToolBar.Parent := Application.GetParentComponent as TFmxObject;
This internal function should also do the trick in case if you know FormFamily
:
function Application.GetDeviceForm(const FormFamily: string): TCommonCustomForm; overload;
Upvotes: 1