Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TFrame descendant example

77 views
Skip to first unread message

Frenk

unread,
Dec 5, 2001, 1:00:56 PM12/5/01
to
has anyone working example of descendant of TFrame (or TForm) that works
inside IDE (is on the (Meni).New -> ... tab) with all stuff (design editors,
...)?

Frenk


Marko Perich

unread,
Dec 5, 2001, 11:04:15 PM12/5/01
to

"Frenk" <franc...@email.si> escribió en el mensaje
news:3c0e5ee0_1@dnews...

The following has properties and events. no property editors. hope it helps

TfrVistaRegistro = class(TFrame)
ToolBar4: TToolBar;
btnAnterior: TBitBtn;
btnSiguiente: TBitBtn;
btnAceptar: TBitBtn;
btnCancelar: TBitBtn;
procedure btnAnteriorClick(Sender: TObject);
procedure btnSiguienteClick(Sender: TObject);
procedure btnAceptarClick(Sender: TObject);
procedure btnCancelarClick(Sender: TObject);
private
{ Private declarations }
{Propiedades}
FAnterior:Boolean;
FSiguiente:Boolean;
FAceptar:Boolean;
FCancelar:Boolean;
FEdicion:Boolean;
{Eventos}
FOnAnterior:TNotifyEvent;
FOnSiguiente:TNotifyEvent;
FOnAceptar:TNotifyEvent;
FOnCancelar:TNotifyEvent;
{Propiedades}
Procedure SetAnterior(Value:Boolean);
Procedure SetSiguiente(Value:Boolean);
Procedure SetAceptar(Value:Boolean);
Procedure SetCancelar(Value:Boolean);
Procedure SetEdicion(Value:Boolean);
public
{ Public declarations }
constructor Create(AOwner:TComponent);override;
procedure TraerAlFrente; virtual;
Published
Property mpi_Anterior:Boolean Read FAnterior write SetAnterior;
Property mpi_Siguiente:Boolean Read FSiguiente write SetSiguiente;
Property mpi_Aceptar:Boolean Read FAceptar write SetAceptar;
Property mpi_Cancelar:Boolean Read FCancelar write SetCancelar;
Property mpi_Edicion:Boolean Read FEdicion write SetEdicion;
Property mpi_OnAnterior:TNotifyEvent Read FOnAnterior write FOnAnterior;
Property mpi_OnSiguiente:TNotifyEvent Read FOnSiguiente write
FOnSiguiente;
Property mpi_OnAceptar:TNotifyEvent Read FOnAceptar write FOnAceptar;
Property mpi_OnCancelar:TNotifyEvent Read FOnCancelar write FOnCancelar;
end;

procedure Register;

implementation

{$R *.DFM}

procedure Register;
begin
RegisterComponents('MPI', [TfrVistaRegistro]);
end;

constructor TfrVistaRegistro.Create(AOwner:TComponent);
begin
Inherited;
ControlStyle:=ControlStyle + [csAcceptsControls];
mpi_Anterior:=False;
mpi_Siguiente:=False;
mpi_Edicion:=False;
end;

Procedure TfrVistaRegistro.SetAnterior(Value:Boolean);
begin
btnAnterior.Enabled:=Value;
FAnterior:=Value;
end;

Procedure TfrVistaRegistro.SetSiguiente(Value:Boolean);
begin
btnSiguiente.Enabled:=Value;
FSiguiente:=Value;
end;

Procedure TfrVistaRegistro.SetAceptar(Value:Boolean);
begin
btnAceptar.Enabled:=Value;
FAceptar:=Value;
end;

Procedure TfrVistaRegistro.SetCancelar(Value:Boolean);
begin
btnCancelar.Enabled:=Value;
FCancelar:=Value;
end;

Procedure TfrVistaRegistro.SetEdicion(Value:Boolean);
begin
if value then
begin
mpi_Cancelar:=true;
mpi_Aceptar:=true;
end
else
begin
mpi_Cancelar:=false;
mpi_Aceptar:=false;
end;
FEdicion:=Value;
end;

procedure TfrVistaRegistro.btnAnteriorClick(Sender: TObject);
begin
if Assigned(mpi_OnAnterior) then mpi_OnAnterior(Self);
end;

procedure TfrVistaRegistro.btnSiguienteClick(Sender: TObject);
begin
if Assigned(mpi_OnSiguiente) then mpi_OnSiguiente(Self);
end;

procedure TfrVistaRegistro.btnAceptarClick(Sender: TObject);
begin
if Assigned(mpi_OnAceptar) then mpi_OnAceptar(Self);
end;

procedure TfrVistaRegistro.btnCancelarClick(Sender: TObject);
begin
if Assigned(mpi_OnCancelar) then mpi_OnCancelar(Self);
end;

procedure TfrVistaRegistro.TraerAlFrente;
begin
Self.Align:=alClient;
Self.BringToFront;
end;

end..


Frenk

unread,
Dec 6, 2001, 4:04:01 AM12/6/01
to
This descendant is in component palete. How do you make this descendant
behave similar to original TFrame??

Frenk

"Marko Perich" <marko...@yahoo.com> wrote in message
news:3c0eee0b_2@dnews...

Sasan Adami

unread,
Dec 6, 2001, 11:57:36 AM12/6/01
to
Frenk wrote:
>
> This descendant is in component palete. How do you make this
> descendant behave similar to original TFrame??

For forms it can be done by registering it with RegisterCustomModule.
See "How can I add published properties to a TForm descendent?" on
http://www.gexperts.org/opentools for an example. I think this works for
frames too.

Sasan.

0 new messages