Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, ExtCtrls;
- type
- TMeuPanel = class(TPanel)
- procedure DblClick(Sender: TObject);
- public
- constructor Create(AOwner: TComponent); reintroduce;
- destructor Destroy; override;
- procedure Remover;
- end;
- TForm1 = class(TForm)
- Button1: TButton;
- ScrollBox1: TScrollBox;
- procedure Button1Click(Sender: TObject);
- private
- { Private declarations }
- topLabel: Integer;
- public
- { Public declarations }
- constructor Create(AOwner: TComponent); reintroduce;
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.dfm}
- { TMeuPanel }
- constructor TMeuPanel.Create(AOwner: TComponent);
- begin
- inherited Create(AOwner);
- OnDblClick := DblClick;
- end;
- procedure TMeuPanel.DblClick(Sender: TObject);
- begin
- Remover;
- end;
- destructor TMeuPanel.Destroy;
- begin
- Caption := 'Excluido';
- inherited;
- end;
- procedure TMeuPanel.Remover;
- begin
- Destroy;
- //PostMessage(Handle, WM_DESTROY, 0, 0);
- //SendMessage(Handle, WM_DESTROY, 0, 0);
- //Perform(WM_DESTROY, 0, 0);
- end;
- procedure TForm1.Button1Click(Sender: TObject);
- var
- Panel: TMeuPanel;
- begin
- Panel := TMeuPanel.Create(Self);
- Panel.Parent := ScrollBox1;
- Panel.Top := topLabel;
- Panel.Height := 15;
- Panel.Caption := 'Label' + IntToStr(topLabel);
- topLabel := topLabel + Panel.Height + 8;
- end;
- constructor TForm1.Create(AOwner: TComponent);
- begin
- inherited Create(AOwner);
- topLabel := 8;
- end;
- end.
Add Comment
Please, Sign In to add comment