We have form that is used as the base class of all of our forms, let's
call it BaseApplication Form. We have another form, say
ChildApplicatio nForm that inherits from BaseApplication Form.
The child form implements an event handler for the Resize event.
Inside BaseApplication Form.Initialize Component, this.ClientSize is set
to a value. On most of our developers' machines, this.ClientSize =
....; does NOT fire the Resize event, which makes us happy, because the
object isn't finished being constructed yet, and our Resize event
handler should be able to assume that the object it is resizing, you
know, actually exists yet.
The problem is that on 2 of our developer machines, "this.ClientSiz e =
....;" DOES fire the event.
So, on these two troublesome machines, here is the order of events we
see as we step through:
We step to the very start of the ChildApplicatio nForm constructor.
This constructor contains a call to its own InitializeCompo nent, but of
course that won't be executed until the base constructor is executed in
full. So we step, which jumps to the base class constructor. Stepping
through the base class constructor, we arrive at the "this.ClientSiz e =
....;" line, and rather than moving to the next line, it jumps to the
CHILD class resize event handler. Inside that handler, we refer to
member variables (controls) that are still null, since
ChildApplicatio nForm.Initializ eComponent has yet to be called.
For the rest of us, the event never fires during construction, so
everything works fine.
So, here are my questions: In this parent class / child class
situation, when the parent class' constructor tries to set
this.ClientSize , *should* the resize event be fired? If so, why does
it not do so for most of us. If not, why does it ever get fired for
some of us?