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;
From what you have said in your comment to clarify ( completely restate ) your problem, you don't need to iterate over all forms.
You are in the context of Form2. As Form2
is "ManualDocked to a Form1 PageControl" then the Parent
property of Form2 will be the PageControl (or more likely the TabSheet)
Given the TabSheet it's trival to get to the Form that is hosting it. You could use something like this:
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;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.