This code collect all TFMXControls in a specified root component. Exam the parent and the component name leading. This code working fine in Win32 32.bit windows target, but not in Nexus (android platform) with page fault in LANC soubrutine first line. I have no idea.. :(
procedure Twmenetlevel.collectXMLControl(root:TComponent;parent:Tcomponent;fieldleading:string;xmlnode:IXMLNode;controlsetting:boolean);
var n:IXMLNode;
procedure feldolgozas(c:tfmxobject);
var s:string;
node:IXMLNode;
begin
if lowercase(copy(c.Name,1,3))=fieldleading then
begin
s:=withoutnumbers(lowercase(c.Name));
node:=xmlnode.ChildNodes.FindNode(s);
if not assigned(node) then
begin
node:=xmlnode.AddChild(s);
end;
case controlsetting of
false: begin //olvasás a kontrollokból az XML-be
if c is tedit then
node.Text:=(c as tedit).Text;
if c is Tcalendaredit then
node.Text:=(c as tCALENDARedit).Text;
if c is TTimeEdit then
node.Text:=(c as TTimeEdit).Text;
if c is TNumberBox then
node.Text:=(c as TNumberBox).Text;
end;
true:begin // a kontrollok beállítása XML szerint
if c is tedit then
(c as tedit).Text:=node.Text;
if c is Tcalendaredit then
(c as tCALENDARedit).Text:=node.Text;
if c is TTimeEdit then
(c as TTimeEdit).Text:=node.Text;
if c is TNumberBox then
(c as TNumberBox).Text:=node.Text;
end;
end;
end;
end;
function isparent(parent:tcomponent;prechild:tfmxobject):boolean;
begin
result:=false;
if assigned(prechild) then
begin
if prechild.parent=parent then
result:=true
else
begin
result:=isparent(parent,prechild.parent);
end;
end;
end;
procedure lanc(c:tcomponent);
var i,j:integer;
cp:tcomponent;
begin
j:=c.ComponentCount;
for i := 0 to c.ComponentCount-1 do
begin
cp:=c.components[i];
if (cp is tfmxobject) then
begin
if (isparent(parent,cp as tfmxobject)) then
begin
feldolgozas(c.components[i] as tfmxobject);
end;
end;
lanc(c.components[i]);
end;
end;
begin
lanc(root);
end;
This not working too but it is very simple. (Win32 working fine) (Tform1 simple mobile form)
procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
s:string;
begin
for i := 0 to self.ComponentCount-1 do
begin
s:=s+self.Components[i].Name;
end;
end;