In a runtime only package, I've defined a TFrame
descendant which publishes the OnLoaded
event:
type
TMyMethod = procedure() of object;
TMyFrame = class(TFrame)
protected
FOnLoaded : TMyMethod;
procedure Loaded(); override;
published
property OnLoaded : TMyMethod read FOnLoaded write FOnLoaded;
end;
implementation
{$R *.dfm}
procedure TMyFrame.Loaded();
begin
inherited;
if(Assigned(FOnLoaded))
then FOnLoaded();
end;
In a designtime only package, I've registered TMyFrame
component as follows:
unit uMyRegistrations;
interface
uses
Classes, uMyFrame;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('MyTestComponents', [
TMyFrame
]);
end;
I've installed the designtime package, I can find TMyFrame
in the tool palette and its OnLoaded
event is shown in the object inspector.
I've dragged a TMyFrame
into a form, then I've assigned the OnLoaded
event by doubleclicking from the object inspector.
After assigning the event, I noticed that an access violation error message appears each time I try to open the form's file in Delphi (It let me open the ".pas" file, but I can't switch to visual designer view).
Did I correctly published the OnLoaded
event? If so, what else is wrong?
Further Informations:
- I'm using Delphi 2007 (don't know if it matters).
- The error also appears by doing the same thing with different parent classes (Not only for
TFrame
descendants).