I have a form with a TPrototypeBindSource Object.
I have a form with a TPrototypeBindSource Object.
It appear that TPrototypeBindSource.OnCreateAdapter event is called before Tform.OnCreate event.
Because of this behavior I have to create my objects within the TPrototypeBindSource.OnCreateAdapter instead of creating them in my TForm.OnCreate event !
Can someone shed some lights on this ? Why are TPrototypeBindSource.OnCreateAdapter events called before the Tform.OnCreate event ?
It appear that TPrototypeBindSource.OnCreateAdapter event is called before Tform.OnCreate event.
Because of this behavior I have to create my objects within the TPrototypeBindSource.OnCreateAdapter instead of creating them in my TForm.OnCreate event !
Can someone shed some lights on this ? Why are TPrototypeBindSource.OnCreateAdapter events called before the Tform.OnCreate event ?
Because it gets triggered from the Loaded method when AutoActivate is True which comes before the Form OnCreate. Turn it False and manually set it Active in your OnCreate after you created the objects.
ReplyDeleteStefan Glienke TPrototypeBindSource 's AutoEdit, AutoPost and AutoActivate are set to false. TPrototypeBindSource.OnCreateAdapter is still called before my form oncreate event.
ReplyDeleteBindList members does also have their AutoActive property set to false.
Then put a breakpoint into OnCreateAdapter and look at the callstack. Something is obviously connected to the PrototypeBindSource which causes it to call the OnCreateAdapter event during form loading.
ReplyDeleteHere we go :
ReplyDeleteData.Bind.ObjectScope.TCustomPrototypeBindSource.Create($65477B0)
:00c2cb2a TCustomPrototypeBindSource.Create + $12
System.Classes.TReader.ReadComponent(nil)
System.Classes.TReader.ReadDataInner(???)
System.Classes.TReader.ReadData($65477B0)
System.Classes.TComponent.ReadState(???)
System.Classes.TReader.ReadRootComponent($65477B0)
System.Classes.TStream.ReadComponent($65477B0)
System.Classes.InternalReadComponentRes(???,???,$65477B0)
System.Classes.InitComponent(TfrmMain)
System.Classes.InitInheritedComponent($65477B0,TCommonCustomForm)
FMX.Forms.TCommonCustomForm.Create(???)
FMX.Forms.TCustomForm.Create(???)
:00924cb7 TCustomForm.Create + $1B
FMX.Forms.TApplication.RealCreateForms
FMX.Platform.Win.TPlatformWin.Run
FMX.Forms.TApplication.Run
Gestion_Stock.Gestion_Stock
:0091741d TApplication.RealCreateForms + $81
fmMain.TfrmMain.FormCreate($65D77B0) is called after ...
Wrong callstack. The top entry should be TBaseObjectBindSource.DoCreateAdapter because that is the method that calls the OnCreateAdapter event. Also I gave you a hint to find the problem yourself, not doing a remote debugging session with you (unless you pay for it ;)
ReplyDelete😁
ReplyDelete