Criação de componente com componentes dentro. ***AVANCADO***

Delphi

02/03/2003

Amigos ,

Eu gostaria de criar um componente , que na verdade , é um TPanel com dois edits e um popup menu . Existe como criá-lo para eu poder ir criando conforme a necessidade ?


Grato.


Psychodad

Psychodad

Curtidas 0

Respostas

Cdaraujo

Cdaraujo

02/03/2003

Caro Amigo,

Fiz um exemplo para vc. Criei um Painel, 2 botões e um PopMenu ligado ao Painel.

Atenciosamente,

Daniel Araújo
ICQ:111769805
www.cdinformatica.hpg.com.br

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Menus;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure CliquePop(Sender: TObject);
procedure CliqueBotao(Sender: TObject);
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var Pnl:TPanel;
Btn1, Btn2:TButton;
PopMn:TPopupMenu;
Mn1: TMenuItem;
begin
{Self = Instância de TForm1}
Pnl := TPanel.Create(Self);
with Pnl do
begin
Parent := Self;
Top := Self.Top div 2;
Left := Self.Left div 2;
Width := 300;
Height := 150;
end;

PopMn := TPopupMenu.Create(Self);
Pnl.PopupMenu := PopMn;
Mn1 := TMenuItem.Create(Self);
Mn1.Caption := ´Menu 1´;
Mn1.OnClick := CliquePop;
PopMn.Items.Add(Mn1);

Btn1 := TButton.Create(Self);
with Btn1 do
begin
Parent := Pnl;
Top := 2;
Left := 5;
Caption := ´Botão 1´;
OnClick := CliqueBotao;
end;
Btn2 := TButton.Create(Self);
with Btn2 do
begin
Parent := Pnl;
Top := 2;
Left := Btn1.Left + Btn1.Width + 5 ;
Caption := ´Botão 2´;
OnClick := CliqueBotao;
end;





end;

procedure TForm1.CliqueBotao(Sender: TObject);
begin
ShowMessage(´Clique Botão - CD Informática - www.cdinformatica.hpg.com.br´)
end;

procedure TForm1.CliquePop(Sender: TObject);
begin
ShowMessage(´CD Informática - www.cdinformatica.hpg.com.br´)
end;

end.


GOSTEI 0
POSTAR