Board index » cppbuilder » Question about Init?

Question about Init?


2008-05-15 05:27:08 PM
cppbuilder33
Dear All,
My program need runtime create some object, which event for these codes
process?
for example:
MemoryStream = new TMemoryStream;
Should I put this code under OnCreate or OnShow or any else?
Thanks for any comments and help
Best regards,
James
 
 

Re:Question about Init?

"James5950" < XXXX@XXXXX.COM >wrote in message
Quote
Dear All,

My program need runtime create some object, which event for these codes
process?
for example:
MemoryStream = new TMemoryStream;
Should I put this code under OnCreate or OnShow or any else?

Don't use the OnCreate event, it can happen before the object it is sent to
has been constructed. Note that the OnShow event can be triggered more than
once.
For an object that needs to persist for the life of a form, create that
object in the form's constructor (and delete it in the destructor). If the
object is needed only for the length of a procedure, it can be created,
used, and deleted in that procedure.
--
Bruce