Hi Kevin and Nigel,
Just finished my solution to this problem:
-Just put a button on your form, called Cancel
-In the clickEvent of the form: THISFORM.CancelProcess = .T.
-In your processloop you must check for THISFORM.CancelProcess if it should be canceled
-Just before the checking:
IF MDOWN() OR CHRSAW()
DOEVENTS
ENDIF
Whenever a key is pressed or a mouse is clicked, a DOEVENTS is executed. When the cancel button is clicked THISFORM.CancelProcess is set to .T.
The advantage of this approach is that the DOEVENTS is only executed when there are events to be executed and doesn't take precious time (DOEVENTS is a quite slow command, when there is nothing to process).
HTH
Walter,