|Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread|
|Messages 1 to 6 of 6 total|
|EWB 2.02 (?) Startup Timing Issue|
|Thu, Oct 22 2015 7:19 AM||Permanent Link|
I am struggling with something that I think should be simple. Create a basic app with a MainForm and a SubForm. Ensure that both are auto-created. I get an exception when I try to access the SubForm from the Mainform in either the MainForm OnCreate or OnShow, both with or without the async keyword mechanism.
I am assuming that SubForm, even though auto-create, has not been created (or its global variable has not been initialised to its instance) at the time when MainForm is created or shown.
So, this begs the question, how do I know when it's "safe" to access SubForm during the app startup process?
FYI, I want to automatically set SubForm's parent to MainForm as part of the app initialisation.
Don't think I've seen this issue before so maybe something has changed?
|Thu, Oct 22 2015 7:38 AM||Permanent Link|
On 22/10/15 22:19, Mark Brooks wrote:
> FYI, I want to automatically set SubForm's parent to MainForm as part of the app initialisation.
You could do something like the following:
1. Turn off auto-create for SubForm.
2. Add SubUnit to uses of MainUnit.
3. Define an OnCreate event for MainForm with the following contents:
If it doesn't work during MainForm OnCreate then try OnShow.
This should parent SubForm to MainForm and display it within MainForm.
|Thu, Oct 22 2015 8:06 AM||Permanent Link|
Yup. That'd work for sure. Just a shame that the extra code is required.
Do you also think that something in the startup "timing" has changed in a recent release?
|Thu, Oct 22 2015 8:26 AM||Permanent Link|
On 22/10/15 23:06, Mark Brooks wrote:
> Do you also think that something in the startup "timing" has changed in a recent release?
Mark, I think Tim mentioned that the main form variable is now
accessible from its OnCreate event whereas it wasn't before (had to use
"self"). This may have altered something.
You can alter the order in which forms are auto-created by
dragging/dropping them in the Forms tab under Project Options. Maybe you
could set SubForm to be created before MainForm so you know it will be
If MainForm is being created first then I guess you could define a
TSubForm.OnCreate event and set Parent:=MainForm in there.
Not sure how you could do it with less code.
|Thu, Oct 22 2015 2:43 PM||Permanent Link|
Tim Young [Elevate Software]
Elevate Software, Inc.
<< Do you also think that something in the startup "timing" has changed in a recent release? >>
Nothing has changed in this regard. It's just a simple matter of X before Y.
|Sat, Oct 24 2015 7:53 AM||Permanent Link|
Tim Young [Elevate Software] wrote:
>> Nothing has changed in this regard. It's just a simple matter of X before Y.
Ok Tim. Maybe it's me. Just didn't see this in the prior version. No worries.