> My question is, when exactly window is being created? Let's assume that
> we have user control placed on any form. Form's contructor create user
> control and adds it to its controls collection. But when exactly this
> window is created? When form window is created ?
Generally, it would be when the control is shown. If you need for the
handle to exist prior to that (in the constructor, for example) you can
call Control.CreateControl(). As long as the Visible property is set,
that will initialize the control's handle as well as those of all the
children. If the Visible property is clear, you can call
Control.CreateHandle() instead. It won't initialize the children, but the
handle for the control itself will be created.
All that said, generally speaking the better solution is to put whatever
code relies on the control handle into the FormShown or Load event
handlers/overrides, by which time the control handle should be initialized.
Pete