procedure TForm_Main.Open_MDI_Child_Form(const aMDIFormClass: TFormClass;
var aMDIForm; aMDIOwner: TComponent);
var i, j: Integer;
aMDIChild: TForm;
aSpeedButton: TSpeedButton;
begin
j := -1;
for i := 0 to Self.MDIChildCount - 1 do
begin
if Self.MDIChildren[i].ClassType = aMDIFormClass then
begin
j := i;
//TSpeedButton(FindComponent('btn_' + Self.MDIChildren[i].Name)).Enabled := True;
TSpeedButton(FindComponent('btn_' + Self.MDIChildren[i].Name)).Font.Color := clMaroon;
TSpeedButton(FindComponent('btn_' + Self.MDIChildren[i].Name)).Font.Style := [fsBold];
end
else
begin
//TSpeedButton(FindComponent('btn_' + Self.MDIChildren[i].Name)).Enabled := False;
TSpeedButton(FindComponent('btn_' + Self.MDIChildren[i].Name)).Font.Color := clBlack;
TSpeedButton(FindComponent('btn_' + Self.MDIChildren[i].Name)).Font.Style := [];
end;
end;
{
if j <> -1 then
begin
aMDIChild := Self.MDIChildren[j];
ShowWindow(aMDIChild.Handle, SW_SHOWMAXIMIZED);
if (not aMDIChild.Visible) then aMDIChild.Visible := True;
aMDIChild.BringToFront;
aMDIChild.Setfocus;
aMDIChild.Show;
TForm(aMDIForm) := aMDIChild;
Exit;
end;
}
if j <> -1 then
begin
SpeedButtonClick(TSpeedButton(FindComponent('btn_' + Self.MDIChildren[j].Name)));
Exit;
end;
aMDIChild := TForm(aMDIFormClass.NewInstance);
TForm(aMDIForm) := aMDIChild;
aMDIChild.Create(aMDIOwner);
aSpeedButton := TSpeedButton.Create(Self);
aSpeedButton.Parent := pnl_Bottom_Client;
aSpeedButton.Name := 'btn_' + aMDIChild.Name;
aSpeedButton.Caption := aMDIChild.Caption;
aSpeedButton.Align := alLeft;
aSpeedButton.Width := Length(aSpeedButton.Caption) * 9;
aSpeedButton.Font.Size := 11;
aSpeedButton.OnClick := SpeedButtonClick;
aSpeedButton.Visible := True;
SpeedButtonClick(aSpeedButton);
end;