Hi Tony, Windows, although it has a sort of multi-tasking environment it's not really a real preemptive RTOS. More like a co-operative threaded OS. That means that within your loop only the code inside the loop is run. Any messages from devices and any screen updating is held off until you call windows to retrieve them. That's actually done in the background and resulted in the call that put you into your method that does the loop.
Within Windows it's never a good idea to create an infinite loop. You're better off to create a timer object and have it run often. Do your code inside the timer method. If that mouse click happens then shut down the timer. Next time you want to run that code start the timer. Otherwise you need to run the getmessage and postmessage methods inside your loop. John Dammeyer > -----Original Message----- > From: Delphi [mailto:[email protected]] On Behalf Of Tony > Foale > Sent: April-02-14 1:45 AM > To: Moderated List for the Discussion of Delphi Programming excluding > Database-related topics > Subject: Exiting loop > > I feel that there is a simple solution to my problem but I seem unable to > find it. > I want to be able to exit from a loop before the exit condition is reached > by means of a mouse click, button press or key press. Any such method > would be acceptable. > I have tried setting the form key-press capture but nothing seems to work. > Here is some psuedo code to show what I want. > > myCondition := true ; > while myCondition do begin > . > . > . > Code to calculate myCondition > . > test for early exit > . > end; > > I want the option to be able to exit the loop prematurely, under user > control, before myCondition is reached, however, key-presses and mouse > operations seem to be ignored. I am sure that this is a common > requirement > but the solution eludes me. > > Regards > > Tony Foale > > > > [email protected] > http://www.tonyfoale.com > http://picasaweb.google.com/tonyfoale > https://www.facebook.com/tony.foale.5 > https://www.youtube.com/user/MotoChassis > _______________________________________________ > Delphi mailing list > [email protected] > http://lists.elists.org/cgi-bin/mailman/listinfo/delphi _______________________________________________ Delphi mailing list [email protected] http://lists.elists.org/cgi-bin/mailman/listinfo/delphi
