procedure TForm1.NewFolioExecute(Sender: TObject); //Dans la barre d'outils on a un bouton intulé "Inserer un nouveau Folio" begin if (ActiveMDIChild is TForm2) then (ActiveMDIChild as TForm2).AddFolio('Folio n°'); end; //Et maintenant voici sont enfant TForm2 - Unit2 <table border=0 cellspacing=0 cellpadding=4 bgcolor=#E0E0E0><tr><td class=code> procedure TForm2.AddFolio(const F:String); var Num:Integer; begin TTabSheet.Create(PageControl1).PageControl:=PageControl1; //Creation de mon nouvelle onglet. Num:=PageControl1.PageCount; PageControl1.Pages[num-1].Caption:=F+IntToStr(Num); //Il aura un nouveau nom du style "Folio n° 2" essai:=TDrawGrid.Create(TabSheet1); //Et a partir d'ici je crée ma nouvelle grille essai.Parent:=TabSheet1; //Mais ca marche pas ! end;
procedure TForm1.NewFolioExecute(Sender: TObject); begin if (ActiveMDIChild is TForm2) then (ActiveMDIChild as TForm2).AddFolio('Folio n°'); end;
procedure TForm2.AddFolio(const F:String); var Num:Integer; begin TTabSheet.Create(PageControl1).PageControl:=PageControl1; Num:=PageControl1.PageCount; PageControl1.Pages[num-1].Caption:=F+IntToStr(Num); TDrawGrid.Create(TabSheet1); essai.Parent:=TabSheet1; end;
//Ici on ce trouve sur TForm1 (en clair c'est la maman !) Unit1 procedure TForm1.NewFolioExecute(Sender: TObject); begin if (ActiveMDIChild is TForm2) then (ActiveMDIChild as TForm2).AddFolio('Folio n°'); end;
//Et maintenant voici sont enfant TForm2 - Unit2 procedure TForm2.AddFolio(const F:String); var Num:Integer; begin TTabSheet.Create(PageControl1).PageControl:=PageControl1; Num:=PageControl1.PageCount; PageControl1.Pages[num-1].Caption:=F+IntToStr(Num); TDrawGrid.Create(TabSheet1); essai.Parent:=TabSheet1; end;