» frame | home browse filter search | refresh | log on
printed zondag 19 mei 2013 10:15:35 from www.yoy.be
Force Application.Run to skip the message loop (from within OnCreate event handler).
Warning: this is a very specific hack an may not apply to other situations.
For a number of projects that check for an update of the program executable on the central file server, from within the main form's OnCreate event handler, I was searching for a way to 'skip'
Application.Run; when an update is found. I was using "
raise EAbort.Create('Auto-update available.');" already to skip the remainder of the OnCreate event handler, but back in the project source (.dpr), Application.Run would start and perform the message loop. I used PostQuitMessage before, but that doesn't seem to always work, a better way would be to skip the message loop altogether.
I used "
if SelfUpdateAvailable then Application.Run;" for some time, but in any new project that would use the auto-update mechanism, you would have to remember to put it in, or the support-calls after the first update for the program would remind you, or have you wondering first what's wrong with the auto-update this time. Anyway, it's better to leave the .dpr just the way Delphi hands it to you since it will modify it later when you add forms or data modules.
So I figured out I could disarm Application.Run by calling this from the 'start auto update' code:
This causes Application.MainForm to be unassigned, and Application.Run to skip starting the message loop, mission accomplished.
location: Application Development > Programming Languages > Object Pascal > Delphi
created: 10/05/2012 13:13:32 « modified: 10/05/2012 13:14:52 (diff) weight: 0
children, tokens, references comments (1)
created: 10/05/2012 13:13:45 «
modified: 10/05/2012 13:13:45