Well,
and I don't use a splash screen to load and initialize stuff. That also usually takes less time than you need to see the logo for me, but you might do more than setting procedures and libraries. Checking all table health states, for example, or loading much data, which I don't like to do.
Any way you do it this can be done in parallel to a splash screen too, if that's non-modal, and for the third time: I say this is
non-modal in my recommendation. No matter how you initialize your application before you addded a splash screen, you stick to it the way it was and stays and is. And the splash screen is really just that - a splash screen only, like that:
main.prg:
Code:
LPARAMETERS ... && if yo had some parameters in yor main.prg, it has to stay the first line
DO FORM spalshscreen && non-modal, toplevel form set alwaysontop=.t. with a timer releasing it, if the user doesn't close it first.
* it does nothing but display a splash image and then can have a timer to release it and the user can close it even beforehand.
* Because there is nothing going on in the splash screen there's no need to hinder the user from closing it, too.
* Rest of the code as it was, with initialization and adding a menu and mainform or whatever your application needs and does
* IMPORTANT: [highlight #FCE94F]This already runs while the splash screen form shows as that form is non-modal[/highlight].
There also is the possibility to start an EXE with the command line option -BFileName,Duration
But that's a bad option, as it merely displays an image and pauses for the specified duration, only after that your EXE really starts. With a non-modal spalsh screen there is neither blocking, nor does it need to stay open as long as the initialization takes because this initialization does not need to be integrated into the splash screen form.
I take it for granted you both know what modal and non-modal form means,, so I don't understand your criticism at all, it's nonsensical. I can understand, Mike, that you might want to keep the splash screen open, when you integrate the intiailization phase into it, but again, you don't have to and I didn't recommend doing so. If you do, of course closng the spalsh screen before the intialization phase is over would even harm the start. I also understand you may integrate these two things together, so the splash screen is more than just a splash screen, but also shows progress of intiallization, like phases of checking database file health, loading initial data and whatever else your complex intialization takes.
But a splash screen running for 3 seconds can close while the initialization still runs, it does not interrupt the initiallization, if it stays where it was, in the main.prg or in the main form your main.prg runs or in procdedures, in an application class init and in any other way, because the spalsh screen I suggested is just a toplevel non-modal form with a tier releasing it, it has nothing else to do nor does it hinder anything else to run, nor does its release interrupt anything else running.
I don't know along which lines you think about my solution, but both of your criticisms is harmful in my eyes, as you make people think it really does not work the way I suggest it. Non-modal forms are not blocking, Griff, and a form only displaying an image is also not immportant to stay open longer than the user needs to see it and he can close it, Mike. A timer also isn't blocking the execution of further code, but only interrupts it after the timer interval for the release of the splash screen form, which takes split seconds. So your initialization time does stay as it was. Initialization may take less time than the interval of the splash screen timer, so your main form appears already while the splash screen still shows, but that's also not immportant, as the user can close the splash screen and the splash screen also automatically closes, which should be done in an interval long enough to recognize the splash screen, say 3-5 seconds or 3000-5000 ms as the timer interval is set in milliseconds. And not to forget, the main screen also will show up behind the splash screen, as I recommended to set alwaysontop=.t. in it. And this setting does not make it the overall desktop foreground, but its on top of every other form of your application not having that property set .t., so it sticks to the front of your main form, if that shows quickly anyway.
What you do in intialization once to speed up the application usage in general, that's a separate topic, I'm not really a fan of such optimizations as a long initiallization phase sometimes makes me think twice, if I use that application. For example I use gimp, but if I can manage to process an image with MSPaints limited fnctionality I may prefer it, as it starts much quicker. The gimp splash screen showing progress of what it's doing isn't making this better. I do like Gimp, as it has so many more features and it pays to start it, but not always. So if a long intialization is your eason for a splash screen, then think twice about what in the initialization really is necessary, some things could be done only one day of the week, for example, others can be done when you actually start the form or featre that needs it and not beforehand already. And then there are optimizations that could be done to improve connecting to a remote server or database, talk to the reponsible persons about that, don't just accept it takes some time.
Chriss