此代码收集指定根组件中的所有 TFMXControl。检查父级和组件名称前导。此代码在 Win32 32.bit windows 目标中运行良好,但在 LANC soubrutine 第一行出现页面错误的 Nexus(android 平台)中无法正常运行。我不知道.. :(
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;
这也不起作用,但它非常简单。(Win32 工作正常)(Tform1 简单移动表单)
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;