I'm trying to remember if setting up some values of components is okay to
do in the form create event. From what I remember in Delphi days of
programming years ago, I think I found out the hard way that setting up
components in the FormCreate event was a bad idea, and I had to resort to
tricks like doing it in the FormShow event instead, using a counter to
only do it on the first show.
Do I recall correctly? Is it bad practice to set up some components on the
form in the formcreate event, because of timing and issues with the
components not all being set up in time? I recall, but cannot be sure,
that in Delphi this led to issues and bugs where if you accessed
components on the form in the formcreate event, it was too soon for some
components as they had not initialized yet. I can't remember for sure
though, and Lazarus may be different.
If any of you know, as this is definitely a been there done that
experience thing... it may have bitten someone else. The problem is it's
been a while since I was bitten by a bug similiar to this so I cannot
remember. Even putting the code in the formshow event, I am not certain
solves all problems, using a counter and on first show only.
It may have also been just a bug with certain components, but not others,
and it may have been an intermittent bug. This, if not already written
about, would be a good article for the wiki or somewhere "best practices"
when creating a form or changing components at run time.
Lazarus mailing list