[英]How to get all the forms from a DLL Delphi Application
I want to get all the forms from a Delphi DLL Application for Casting, something like this but not using MDIChild forms but fsNormal forms: (This is from Delphi 4, I need something similar in Delphi RAD STUDIO but I dont know how to accomplish this )
for i:= Application.MainForm.MDIChildCount-1 downto 0 do
if (Application.MainForm.MDIChildren[i] is FormNameNeeded) then
begin
variable := (Application.MainForm.MDIChildren[i] as FormNameNeeded).FunctionNeeded;
break;
end;
根据您在评论中所说的澄清(完全重申)您的问题,您不需要遍历所有 forms。
您在 Form2 的上下文中。 由于Form2
是“ManualDocked to a Form1 PageControl”,那么 Form2 的Parent
属性将是 PageControl(或者更可能是 TabSheet)
鉴于 TabSheet,访问托管它的表单很简单。 你可以使用这样的东西:
var
pCandidate: TComponent;
begin
pCandidate:=Self.Parent;
if(pCandidate<>nil) then
begin
while((pCandidate<>nil) And not(pCandidate is TForm1)) do
pCandidate:=pCandidate.Owner;
end;
if(pCandidate<>nil) then
TForm1(pCandidate).FunctionNameNeeded();
end;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.