Ver Mensaje Individual
  #4  
Antiguo 22-02-2022
cloayza cloayza is offline
Miembro
 
Registrado: may 2003
Ubicación: San Pedro de la Paz, Chile
Posts: 913
Reputación: 23
cloayza Tiene un aura espectacularcloayza Tiene un aura espectacular
Si me lo permite, expongo una variación.

Código Delphi [-]
unit Unit2;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
  TMDIChild = class(TForm)
    Edit1: TEdit;
    Label1: TLabel;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
    constructor Create(AOwner: TComponent; AParametro:String);
  end;

var
  MDIChild: TMDIChild;

implementation

{$R *.dfm}

constructor TMDIChild.Create(AOwner: TComponent; AParametro:String);
begin
     inherited Create(AOwner);

     Edit1.Text := AParametro;
end;

procedure TMDIChild.FormClose(Sender: TObject; var Action: TCloseAction);
begin
     Action := caFree;
end;

end.

Código Delphi [-]
unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;

type
  TMDIForm = class(TForm)
    Panel1: TPanel;
    Button4: TButton;
    Button3: TButton;
    Button2: TButton;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
  private
    { Private declarations }
    procedure CallMDIChild(const nro: Integer);
  public
    { Public declarations }
  end;

var
  MDIForm: TMDIForm;

implementation {$R *.dfm}

uses Unit2;

procedure TMDIForm.CallMDIChild(const nro: Integer);
begin
  MDIChild := TMDIChild.Create(Self, IntToStr(nro));
end;

procedure TMDIForm.Button1Click(Sender: TObject);
begin
  CallMDIChild(111);
end;

procedure TMDIForm.Button2Click(Sender: TObject);
begin
  CallMDIChild(222);
end;

procedure TMDIForm.Button3Click(Sender: TObject);
begin
  CallMDIChild(333);
end;

procedure TMDIForm.Button4Click(Sender: TObject);
begin
 CallMDIChild(444);
end;

end.

Saludos cordiales
Responder Con Cita