Freeeee 0 Posted yesterday at 02:44 PM Is there any way of running code at program start up. right now it looks like code only runs when you click on a control on the form. Is there any way of running code before you get to that point Example ap creates and Ini.file that records where you were at in the last time you used it. is it possible to read the ini file without having to click on something in the form when the form appears?? If so, where do you place that code? Does it need to be a procedure? Does it have to have a 'special' name? Share this post Link to post
Remy Lebeau 1633 Posted yesterday at 03:01 PM (edited) If you need to run code that is related to your UI, you can use your MainForm's OnCreate event. If you need to run code sooner than that, then you can add code in your project's .dpr file before Application.Run() is called. Or, you can put code in the initialization section of any .pas file in your project. Edited yesterday at 03:02 PM by Remy Lebeau Share this post Link to post
DJof SD 13 Posted yesterday at 03:01 PM Let's assume you are asking about Windows and a GUI app. One place to start looking is the form OnCreate method, see: https://docwiki.embarcadero.com/Libraries/Alexandria/en/Vcl.Forms.TForm.OnCreate Share this post Link to post
DelphiUdIT 257 Posted yesterday at 03:39 PM Or you can create a Thread, where you can run every code you need without UI interactions. https://docwiki.embarcadero.com/Libraries/Athens/en/System.Classes.TThread Share this post Link to post
Remy Lebeau 1633 Posted yesterday at 04:21 PM 40 minutes ago, DelphiUdIT said: Or you can create a Thread, where you can run every code you need without UI interactions. That's a little overkill just for loading an ini file. And you'd still need startup code to start the thread. Share this post Link to post