Hi Koos,
DOEVENTS is the right approach, but remember that now VFP will process other buttons too. For example, if the user clicks on the close button of the form, it will run that code, then try to resume the scan loop. (Which will fail because the table has been closed in the unload of the form). In my base form class I have a WaitMode(), which takes a .T. or .F. parameter indicating if we are starting the wait or are done. This message disables the close button of the form, among other things, and ensures that only the cancel button is enabled. The Cancel button can have the Cancel property set to True, so Esc 'clicks' the button.
>Greg,
>
>Thanks, DOEVENTS is the trick I needed.
>
>
>>In conjunction with Tore first suggestion, place a DOEVENTS statement inside the loop. This should allow your application to see the user click the stop button.
>>
>>>Something like this might do the job:
>>>yourform.cmdStopAction.Click: yourform.lStopAction=.T.
>>>yourform.cmdStartAction.Click: yourform.lStopAction=.F.
>>>SCAN WHILE !yourform.lStopAction
>>> ..Process a record
>>>ENDSCAN
>>>Or simply
>>>yourform.cmdStopAction.Click: KEYBOARD '{ESC}' PLAIN
>>>
>>>>Dear all,
>>>>
>>>>In a VFP 8.0 application we have a screen where you can click on a button to process a certain amount of records of a table with some calculations. It may take some time and the user should be able to stop the process by pressing another button. But while the program scans through the records, there is no way you can press another button (the cursor changes to the hour glass cursor). We could rely on a good old Escape but we rather have a cancel button. Anybody knows how to do this?
>>>>
>>>>Thanks,
>>>>
>>>>Koos Veel.
Charlie