Startup of forms in a VCL application

I have a very standard VCL Forms application generated using the C++Builder 2006 IDE. I use the constructor to do a significant amount of initialisation, especially some communication classes.

I have added a non-modal logging form which records, via simple event handlers, some of the communication activity. The logging form is created after the main form starts so I miss the initial activity.

I realise the simple answer is to change the order of the Application->CreateForms in the WinMain, but this file is generated by C++Builder and I don't like playing with auto-generated files.

Is there a simple way to convice C++Builder to start my logging first? or maybe to not start it at all so I can in the main form constructor?

I would really like to start all the comms in the main form when the message processing starts (when Application->Run is running) as I generate a lot of messages in the constructor. The logging form would work fine then as well.   I cannot find an event that happens once after start of a form.  A go button would do the trick but is not prefered as the application is used by very unskilled operators.

Does anyone have a mechanism for starting stuff after a form starts?

Thanks
jrgrobinsonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SwissKnifeCommented:
Hello
Can you move your init code from the contructor to the FormLoad event. May be you can first create your logging form  here and do the init stuff now.
0
jrgrobinsonAuthor Commented:
I have used and set the FormLoad event in VSC++ .NET, it is exactly the right event but the VCL TForm documentation doesn't mention a event.

TForm has an OnCreate event. In my research I have found much advice saying use that event or the constructor but not both as there is some unpredicatblity about what happens when.

0
jrgrobinsonAuthor Commented:
oops,   "...doesn't mention a FormLoad event..."
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

jrgrobinsonAuthor Commented:
I think I have solved the first part of my problem. In Project->Options->Forms, you can set any form in the application to be 'Auto Create' or not. With the form not 'Auto Create', the instantiation can then be put into the main form constructor (or onCreate event) and the start-up position controlled.

I haven't found an event that occurs after all forms have been created and the message processing started in an application.
0
kode99Commented:
If you change the order of the Project->Options->Forms list of autocreated forms it will change the source of the main file with the Application->CreateForm calls.  So have no fear of editing this order,  either in the source file or from the project options - they are the same thing - so if you modify the source it changes the project options and vice-versa.  To change the order in the options just click on a form in the list and drag it into position you want.

The alternate would be to do as you have described and just create your log form at run time in source before you do anything you want to log.

I do a lot of database stuff and the datamodules always have to be loaded first.  I typically just do it through the project options.

Probably worth noting that autocreated forms are using up resources even if they are not visible.  Often the only autocreated forms I have are the main form and datamodules.

There is not a equivalent event to the FormLoad event mentioned.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jrgrobinsonAuthor Commented:
Thanks, I had come to the conclusion that stopping the AutoCreate for all but the main form and starting every thing else in that is an effective solution. I tried your suggestion of shifting the order and that does work too. I was reluctant to change auto-generated files so shifting order in the options is a good result.  
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.