Freeeee 0 Posted 10 hours ago 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 1632 Posted 9 hours ago (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 9 hours ago by Remy Lebeau Share this post Link to post
DJof SD 13 Posted 9 hours ago 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 9 hours ago 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 1632 Posted 8 hours ago 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