Property OnCreate not found

When I define an EventHandler for the OnCreate event of a (derived) TWebFrame, the frame raises an exception because it cannot find the OnCreate property.

  1. Please repair
  2. What is an alternative way to set some parameter defaults?

The next method raises the exception:
function FindPropInfo(Instance: TObject; const PropName: String
): TTypeMemberProperty;
begin
Result:=GetPropInfo(TypeInfo(Instance), PropName);
if Result=nil then
raise EPropertyError.CreateFmt(SErrPropertyNotFound, [PropName]);
end;

The value of PropName is OnCreate;

As TWebFrame does not have an OnCreate event, I assume you created your own class and added this OnCreate event?

How should I reproduce this?

I added the OnCreate to a derived TWebFrame:

type
TFrame1 = class(TWebFrame)
WebTableControl1: TWebTableControl;
private
{ Private declarations }
FOnCreate: TNotifyEvent;
public
{ Public declarations }
published
property OnCreate: TNotifyEvent read FOnCreate write FOnCreate;
end;


and I use this OnCreate from the form where the frame is hosted

type
  TForm2 = class(TWebForm)
    Frame11: TFrame1;
    procedure WebFormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure MyFrameCreate(Sender: TObject);
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}
uses
   rtti, typinfo;

procedure TForm2.MyFrameCreate(Sender: TObject);
begin
  console.log('in oncreate');

  FindPropInfo(Frame11,'oncreate');
end;

procedure TForm2.WebFormCreate(Sender: TObject);
begin
  frame11.OnCreate := MyFrameCreate;
end;

but I cannot see an error here?

Attached a file that shows the bug. I have a TFBasis derived from TWebFrame and a TFBasisLijst derived from TFBasis. In TFBasisLijst the property OnCreate is exposed (which apparently is incorrect) in the ObjectInspector.

TMSShowBug.zip (1.6 MB)

We could reproduce it and we are investigating.

Not sure what flow you used to create the descending frame, but the issue is in the DFM file for the descending frame.

There should be

inherited FBasisLijst: TFBasisLijst

instead of

object FBasisLijst: TFBasisLijst

Please correct it and it should be fine

Thank you again. This solved the issue. And that on a Sunday! You must like your job very much. I have no idea where this error originated from, but somewhere apparently I did something wrong.

Peter

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.