jrgrobinson
asked on
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
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
ASKER
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.
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.
ASKER
oops, "...doesn't mention a FormLoad event..."
ASKER
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.
I haven't found an event that occurs after all forms have been created and the message processing started in an application.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
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.