1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
| unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, ComCtrls ;
type
TfrmMain = class(TForm)
Button1: TButton;
ScrollBox1: TScrollBox;
procedure Button1Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
procedure CreateItems(sName : string);
procedure MaJTB(Sender: TObject; var TrB: TTrackBar; var Lbl :TLabel);
end;
var
frmMain: TfrmMain;
I : Byte;
implementation
{$R *.DFM}
procedure TfrmMain.MaJTB(Sender: TObject; var TrB: TTrackBar; var Lbl :TLabel);
begin
Lbl.Caption := IntToStr(TrB.Position);
end;
procedure TfrmMain.CreateItems(sName : string);
var
MonPanel : TPanel;
lblEtat : TLabel;
TB : TTrackBar;
Compo : TComponent;
CompoTB : TComponent;
begin
MonPanel := TPanel.Create(frmMain.ScrollBox1);
With MonPanel do
begin
Align := alTop;
Name := 'Mon' + sName;
Height := 260;
Parent := frmMain.ScrollBox1;
//Caption := '';
Caption := Name;
Locked := True;
Visible := True;
end;
Compo := TPanel(frmMain.ScrollBox1.findComponent('Mon' + sName));
lblEtat := TLabel.Create(Compo);
With lblEtat do
begin
Top := 44;
Left := 8;
Name := 'ET' + sName;
Parent := TPanel(Compo);
Caption := '0';
Visible := True;
end;
CompoTB := TTrackBar(frmMain.ScrollBox1.findComponent('Mon' + sName));
TB := TTrackBar.Create(CompoTB);
With TB do
begin
Left := 8;
Top := 64;
Max := 12;
Name := 'TB' + sName;
Parent := TTrackBar(CompoTB);
Visible := True;
OnChange := Self.MaJTB(Il_Manque_un_truc,TB,lblEtat);
end;
Application.ProcessMessages;
end;
procedure TfrmMain.Button1Click(Sender: TObject);
begin
Inc(I);
CreateItems('Conteneur' + IntToStr(I))
end;
procedure TfrmMain.FormActivate(Sender: TObject);
begin
I := 0;
end;
end. |
Partager