procedure TForm1.Button1Click(Sender: TObject); begin .... ...... Form2.PageControl1.Pages[0].Caption: ='Page n°'+IntToStr(1); Form2.AddTabSh(false,'Page n°'); Nbr:= 1; end ;
procedure TForm1.Button2Click(Sender: TObject); begin if (ActiveMDIChild is TForm2) then (ActiveMDIChild as TForm2).AddTabSh(true,'Page n°'); end;
procedure TForm2.AddTabSh(Add: Boolean; const F:String); begin if Add then begin .... ...... On créer le TTabSheet avec le TImage ..... ...... with Image1 do begin Parent: =TabSh; Align:= alClient; OnMouseDown:=ImageMouseDown; end ; Act: =PageControl1.TabIndex+1; end; end else Image1.OnMouseDown:= ImageMouseDown; end ;
Procedure TForm2.ImageMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin (sender as Timage).canvas.lineTo(x,y); end; end.
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionprocedure TForm1.Button1Click(Sender: TObject); begin Form2:= TForm2.Create(Application); Form2.Caption:=('Dossier n°'+IntToStr(MDIChildCount)); Form2.PageControl1.Pages[0].Caption:='Page n°'+IntToStr(1); Nbr:=1; end ;
procedure TForm1.Button2Click(Sender: TObject); begin if (ActiveMDIChild is TForm2) then (ActiveMDIChild as TForm2).AddTabSh('Page n°'); end;
procedure TForm2.AddTabSh(const F:String); begin if Nbr < 50 then begin TTabSheet.Create(PageControl1).PageControl: =PageControl1; Nbr:= PageControl1.PageCount; PageControl1.Pages[Nbr-1].Caption:=F+IntToStr(Nbr); PIndex:=PageControl1.ActivePageIndex+1; if Nbr-PIndex <> 0 then PageControl1.ActivePageIndex: =Nbr-1; TabSh:= PageControl1.ActivePage; Image1:=TImage.Create(TabSh); with Image1 do begin Parent: =TabSh; Align:= alClient; end ; Act: =PageControl1.TabIndex+1; end; end;
procedure TForm2.Image1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin Image1.Canvas.Create; Image1.Canvas.LineTo(x,y); end;
procedure TForm2.PageControl1Change(Sender: TObject); begin Act:= PageControl1.TabIndex+1; end ;
procedure TForm1.Button3Click(Sender: TObject); var Z: Integer; begin if (ActiveMDIChild is TForm2) then with (ActiveMDIChild as TForm2).PageControl1 do begin if Nbr>1 then begin ActivePage.Free; Nbr: =PageCount; Act:= TabIndex+1; for Z: =Act to Nbr do Pages[Z-1].Caption:='Page n°'+IntToStr(Z); end; end; end;