Estoy intentando mediante el uso de application.mainform, en la creacion de un componente, y cuando este en ejecucion, que no en diseño, almacenar, caso que este definido en el form, un evento, para poder ejecutarlo despues del que se debe ejecutar.
Por ejemplo,
Código Delphi
[-]
tpanelcentrable=class(tcustompanel)
...
FonResize_del_form: TnotifyEvent;
FOnResize_delCompo:TnotifyEvent;
...
Property OnResize: TnotifyEvent read FOnResize_del_Compo Write
FOnResize_del_Compo;
....
constructor TPanelCentrable.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
if not (csDesigning in ComponentState) then
begin
if assigned(tform(application.MainForm).OncanResize) then
fonresize_del_form:=tform(application.MainForm).OncanResize;
tform(application.MainForm).OnCanResize:=formresize;
end;
end;
Procedure TpanelCentrable.formresize(sender:tObject);
begin
Centrar(self,self.parent);
if assigned(FOnResize_del_form) then
FOnResize_del_form(sender);
if assigned(FOnresize_del_compo) then
FOnResize_del_compo(sender);
end;
...
Pero, cuando ejecuto, antes de hacer nada, me salta un error del tipo:
Project programa1.exe raised exception class EAccesViolation with message 'Acces
violation at adrress.....
y en el IDE se queda en;
if assigned(tform(application.MainForm).OncanResize) then
Por favor, ¿alguien me puede ayudar con este tema?
Gracias.
Nove
