When to use the OnCreate, OnShow, OnActivate, and OnPaint events of a TForm (Views: 105)
When to use the OnCreate, OnShow, OnActivate, and OnPaint events of a TForm
Stuff that needs to be done to initialize the object (initializing variables and nested objects, etc.) should be done in the OnCreate event handler. That gets called as part of your constructor logic and is guaranteed to only be called once in the life of any object.
Stuff that needs to be drawn should always be done in the OnPaint event handler. Drawing for your form (except for other controls or components) must be done there or you won't have a chance to refresh it when needed. This gets called lots of times in the life of a form.
OnShow gets called when the form is first shown and when it is made visible after being hidden. This generally applies only to secondary forms. It should not be used to initialize anything.
OnActivate seems to get called at random intervals. Put your hand in that lion's mouth only if you have a surplus of digits ...
<< Back to main page