juniorparreira Aprendiz

Registrado: Terça-Feira, 3 de Janeiro de 2006 Mensagens: 118
|
Enviada: Qua Ago 11, 2010 11:05 pm Assunto: Criação de componentes |
|
|
Boa noite amigos, estou tentando criar uma Toolbar personalizada, o que fiz foi o seguinte coloquei no forme uma Toobar e um ImageList e na toobar acrescentei 8 botoes e um txtbox, a funcionalidade e a seguinte o estado dos botões retornar e gravar ficam desabilitados quando e dado um click no botão de adicionar os outros botões são desabilitados e os botões de voltar e gravar são habilitados.
Feito tudo isso foui em componentes e selecionei create componentes tamplate.
Ate ai tudo bem o componente foi criado e eu consigo utilizalo, so que o codigo fonte não fica encapsulado, ele fica disponivel, como ocutar esse codigo.
Codigo fonte:
unit unitCOMPONENTE;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ImgList, StdCtrls, ComCtrls, ToolWin;
type
TForm1 = class(TForm)
ToolBar1: TToolBar;
cmdINCLUIR: TToolButton;
cmdALTERAR: TToolButton;
cmdEXCLUIR: TToolButton;
CMDpesquisar: TToolButton;
cmdIMPRIMIR: TToolButton;
ToolButton6: TToolButton;
cmdVOLTAR: TToolButton;
cmdEXECUTAR: TToolButton;
ToolButton9: TToolButton;
cmdSAIR: TToolButton;
txtACAO: TEdit;
ImageList1: TImageList;
procedure cmdINCLUIRClick(Sender: TObject) ;
procedure cmdALTERARClick(Sender: TObject) ;
procedure cmdEXCLUIRClick(Sender: TObject) ;
procedure CMDpesquisarClick(Sender: TObject) ;
procedure cmdIMPRIMIRClick(Sender: TObject) ;
procedure cmdVOLTARClick(Sender: TObject) ;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
procedure TForm1.cmdALTERARClick(Sender: TObject);
begin
txtACAO.Text:= 'ALTERAR';
cmdINCLUIR.Enabled:= false;
cmdALTERAR.Enabled := true;
cmdEXCLUIR.Enabled:= false;
CMDpesquisar.Enabled:= false;
cmdIMPRIMIR.Enabled:=false;
cmdVOLTAR.Enabled:= true;
cmdEXECUTAR.Enabled:= true;
inherited;
end;
procedure TForm1.cmdEXCLUIRClick(Sender: TObject);
begin
txtACAO.Text:= 'EXCLUIR';
cmdINCLUIR.Enabled:= false;
cmdALTERAR.Enabled := false;
cmdEXCLUIR.Enabled:= true;
CMDpesquisar.Enabled:= false;
cmdIMPRIMIR.Enabled:=false;
cmdVOLTAR.Enabled:= true;
cmdEXECUTAR.Enabled:= true;
inherited;
end;
procedure TForm1.cmdIMPRIMIRClick(Sender: TObject);
begin
txtACAO.Text:= 'IMPRIMI';
cmdINCLUIR.Enabled:= false;
cmdALTERAR.Enabled := false;
cmdEXCLUIR.Enabled:= false;
CMDpesquisar.Enabled:= false;
cmdIMPRIMIR.Enabled:=true;
cmdVOLTAR.Enabled:= true;
cmdEXECUTAR.Enabled:= true;
inherited;
end;
procedure TForm1.cmdINCLUIRClick(Sender: TObject);
begin
txtACAO.Text:= 'incluir';
cmdINCLUIR.Enabled:= true;
cmdALTERAR.Enabled := false;
cmdEXCLUIR.Enabled:= false;
CMDpesquisar.Enabled:= false;
cmdIMPRIMIR.Enabled:=false;
cmdVOLTAR.Enabled:= true;
cmdEXECUTAR.Enabled:= true;
inherited;
end;
procedure TForm1.CMDpesquisarClick(Sender: TObject);
begin
txtACAO.Text:= 'PESQUISAR';
cmdINCLUIR.Enabled:= false;
cmdALTERAR.Enabled := false;
cmdEXCLUIR.Enabled:= false;
CMDpesquisar.Enabled:= true;
cmdIMPRIMIR.Enabled:=false;
cmdVOLTAR.Enabled:= true;
cmdEXECUTAR.Enabled:= true;
inherited;
end;
procedure TForm1.cmdVOLTARClick(Sender: TObject);
begin
txtACAO.Text:= '';
cmdINCLUIR.Enabled:= true;
cmdALTERAR.Enabled := true;
cmdEXCLUIR.Enabled:= true;
CMDpesquisar.Enabled:= true;
cmdIMPRIMIR.Enabled:=true;
cmdVOLTAR.Enabled:= false;
cmdEXECUTAR.Enabled:= false;
inherited;
end; |
|