Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Why can we create child components in Form1's constructor?


This question is answered.


Permlink Replies: 3 - Last Post: Feb 19, 2016 11:46 PM Last Post By: erchuan zhao
erchuan zhao

Posts: 17
Registered: 2/18/16
Why can we create child components in Form1's constructor?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 6, 2016 2:59 AM
Why can we create child components and set their properties in Form1's constructor?
When are the form and it's child controls showed?
thanks
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Why can we create child components in Form1's constructor? [Edit]
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 6, 2016 12:30 PM   in response to: erchuan zhao in response to: erchuan zhao
erchuan wrote:

Why can we create child components and set their properties in Form1's
constructor?

Why not? The Form object has been constructed before your derived constructor
code starts running. Where's the confusion?

When are the form and it's child controls showed?

If the Form's Visible property is false at design-time, it is not shown at
run-time until your code calls Show() on it.

If the Form's Visible property is true at design-time, it is shown immediately
when its HWND is created during construction.

--
Remy Lebeau (TeamB)
erchuan zhao

Posts: 17
Registered: 2/18/16
Re: Why can we create child components in Form1's constructor? [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 6, 2016 10:41 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
erchuan wrote:

Why can we create child components and set their properties in Form1's
constructor?

Why not? The Form object has been constructed before your derived constructor
code starts running. Where's the confusion?
Because I know little about the execution sequence of the TForm1's constructor and Form1's creation and show and the child component's creation (dynamically created in TForm1's constructor) and show, for TForm1 is not a "ordinary" class.
erchuan zhao

Posts: 17
Registered: 2/18/16
Re: Why can we create child components in Form1's constructor? [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 19, 2016 11:46 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Cound you pls have some words about the execution sequence? thanks!
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02