yoy.be "Why-o-Why"

2012 ...

januari (3) februari (5) maart april (6) mei (2) juni (1) juli (2) augustus september (5) oktober (1) november (2) december

Force Application.Run to skip the message loop (from within OnCreate event handler).

2012-05-10 13:13  i3020  delphi  [permalink]

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.

twitter reddit linkedin facebook


2012-05-10 21:06  r1716  delphi freeware  [permalink]


- issue expanding closest line above for lower indentation-levels over blank lines
- shell context menu on files/folders items
- command line parameters support:
    DirFind [<options>] <search path> [<filter filenames> [<exclude filenames> [<search pattern>]]]
      /i  ignore case
      /m  multi line
      /a  count all matches
      (/-... to disable, default settings are loaded from previous session)

twitter reddit linkedin facebook