re,
ah. au final je t'ai fait un exemple directement:
uses ...... , ChildMDI_frm;
type TfrmMainMDI = class(TForm) ToolBar1: TToolBar; tlbByConstruct: TToolButton; tlbByParam: TToolButton; procedure tlbByParamClick(Sender: TObject); procedure tlbByConstructClick(Sender: TObject); private fChildForm : TfrmChildMDI;//instance unique end;
var frmMainMDI: TfrmMainMDI;
implementation
{$R *.dfm}
procedure TfrmMainMDI.tlbByConstructClick(Sender: TObject); var param : string; begin param := InputBox('Entre param', '','');
// pass by constructor (news instance every time) TFrmChildMDI.CreateWithParam(self,param);
end;
procedure TfrmMainMDI.tlbByParamClick(Sender: TObject); var param : string; begin // pass by param (unic instance)
if not assigned (fChildForm) then begin fChildForm := TFrmChildMDI.Create(self); end;
param := InputBox('Entre param', '',''); fChildForm.param := param;
end;
type TfrmChildMDI = class(TForm) Label1: TLabel; private fParam : string; procedure Setparam(const Value: string); public property param:string read Fparam write Setparam;
constructor CreateWithParam(AOwner: TComponent; aParam : string); end;
var frmChildMDI: TfrmChildMDI;
implementation
{$R *.dfm}
{ TfrmChildMDI }
procedure TfrmChildMDI.Setparam(const Value: string); begin Fparam := Value; label1.Caption := Fparam; end;
constructor TfrmChildMDI.CreateWithParam(AOwner: TComponent; aParam: string); begin Create(AOwner); Setparam(aParam); end;
bonne continuation dans le monde de Delphi !
Loda
Se poser les bonnes questions est le premier pas pour trouver les bonnes réponses.
|