got here a two Forms which are both set to fsMDIForm . And two Child Forms fsMDIChild.
When I run the Application it looks like both Parent Forms are correctly created because I can see the Space where the Child Forms would show up.
But for some reason the the Second MDIForm which is created from the Main MDI Form the Children are not being displayed, instead they are created on the Main MDI Form .
This is how the Second MDI Form is created
procedure TMain.menChefReportClick(Sender: TObject);
begin
Timer1.Enabled:=false;
CloseAllMDIChildren;
Application.CreateForm(TChefReport, ChefReport);
ChefReport.PopupParent:=Main;
ChefReport.ShowModal;
ChefReport.Free;
ChefReport:=nil;
OpenAllMDIChildren;
Timer1.Enabled:=true;
end;
This closes all MDI Children for the Main Form , I am doing this because I am displaying Live data which is not required as long as I am in the Second MDI Form.
On the Second MDI form I am trying to create the Children like this :
procedure TChefReport.OpenAllMDIChildren;
var AQuery : TADOQuery;
Y : integer;
begin
AQuery := TADOQuery.Create(nil);
try
AQuery.Connection:=dmConnection.XLR;
AQuery.LockType:=ltReadOnly;
AQuery.SQL.Clear;
AQuery.SQL.Add('select Line from LINE_SETTINGS order by line');
AQuery.Open;
AQuery.DisableControls;
Y:=0;
while not AQuery.Eof do
begin
Application.CreateForm(TChefReportLine,ChefReportLine);
ChefReportLine.Caption:='Linie Nr. '+AQuery.FieldByName('Line').AsString;
ChefReportLine.FLine:=AQuery.FieldByName('Line').AsInteger;
ChefReportLine.Top:=0;
ChefReportLine.Left:=0;
Y:=Y+ChefReportLine.Height;
AQuery.Next;
end;
finally
AQuery.Free;
end;
end;
It does create them . But unfortunately on the Main MDI Form .
Is it possible and how do I create them on the Second MDI Form ( ChefReport ) ?
Thank you!
UPDATE
Solutions was here : Allow multiple MDI Parent Forms on same Application
And I create the Children Like this :
procedure TChefReport.OpenAllMDIChildren;
var AQuery : TADOQuery;
Y : integer;
ChefReportLine : TChefReportLine;
begin
AQuery := TADOQuery.Create(nil);
try
AQuery.Connection:=dmConnection.XLR;
AQuery.LockType:=ltReadOnly;
AQuery.SQL.Clear;
AQuery.SQL.Add('select Line from LINE_SETTINGS order by line');
AQuery.Open;
AQuery.DisableControls;
Y:=0;
while not AQuery.Eof do
begin
ChefReportLine := TChefReportLine.Create(ChefReport);
ChefReportLine.Caption:='Linie Nr. '+AQuery.FieldByName('Line').AsString;
ChefReportLine.FLine:=AQuery.FieldByName('Line').AsInteger;
ChefReportLine.Top:=Y;
ChefReportLine.Left:=0;
Y:=Y+ChefReportLine.Height;
AQuery.Next;
end;
finally
AQuery.Free;
end;
end;