What I do is create a global boolean named gCancelRequested which is False when I start the loop.
Whithin the loop always include a call to Application.ProcessMessages; For the button click method on the button that requests the cancel, just set gCancelRequested := True; Finally, in the loop control, in addition to testing MyCondition also test for gCencelRequested. That should do it! On Wed, Apr 2, 2014 at 4:44 AM, Tony Foale <[email protected]> wrote: > 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
