DoEvents vs. Application.ProcessMessages
Posted on 1998-07-17
I'm a VB programmer who is in the process of learning Delphi 3 (now 4). I have to say -- It's Great! :-)
However, I am trying to rewrite one of my old VB programs in Delphi 3 which I use the following "wait" routine:
Public Sub Wait(WaitSeconds As Single)
'usage: Wait(10) - waits for 10 seconds
Dim StartTime As Single
StartTime = Timer
Do While Timer < StartTime + WaitSeconds
In Delphi (this is only one of a couple ways to do it):
procedure Wait(Msec : longint);
b : longint;
b := GetTickCount;
while (GetTickCount - b) < Msec do
The problem is the difference between DoEvents and Application.ProcessMessages. Using the VB code I can still exit the program by unloading the form, or simply "ending" it. The doevents allows this to happen before the wait time is over. Delphi allows me to minimize, push buttons, etc, but will not execute anything (or let me end the program) until the wait time has ticked out. This has been frustrating.
Is there a different way to interupt the wait time and end the program, etc.??? Any help or sample code would be greatly appreciated.