Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
We interrupt this program...
Message
De
05/12/1997 13:23:18
 
 
À
05/12/1997 12:57:01
Elyse Pomerantz
Dynamic Data Concepts, Inc.
Brooklyn, New York, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00064056
Message ID:
00064071
Vues:
28
>In my startup program I have ON KEY LABEL ESC DO EscKey IN MyProcFile.
>The procedure is as follows, where 'Nothing' is a procedure that just has a 'RETURN.'
>
>PROCEDURE EscKey
>if type("_screen.activeform")="O"
> if pemstatus(_screen.activeform,"OnEscape",5)
> _screen.activeform.OnEscape()
> else
> _screen.activeform.release()
> endif
>else
> do Nothing
>endif
>
>My goal is to let each form decide how to handle the escape key. Mostly this works, but sometimes, particularly while calling up one form from another (the cursor is an hourglass), the user gets the FoxPro message "Program Error: ***Interrupted***". Why is that? How do I avoid it?
>
>Thanks
>Elyse

You need to SET ESCAPE OFF. When SET ESCAPE is on, FoxPro interrupts any executing code and asks if you want to continue executing or cancel the operation. The nature of ON KEY LABEL also interrupts any executing code to run whatever code you specify, but will then continue executing the code that was interrupted.

A better solution though, (IMHO) would be to rethink the way you let the form decide how to handle the escape key. If you set the form's keypreview property to .T., then you can catch any key that is pressed while the form is active in the form's keypress event. In my opinion, this would be the place to handle what you want to do.

Still another solution, and one that I have used on occasion, is to create a command button, locate it off screen, and set it's cancel property to .T.. Then you can write any code you want in the command's click event, and it will execute whenever the user hits escape in that screen.

ON KEY LABELS are generally a dangerous strategy because of their very nature. Interrupting any running code, no matter what, can produce unpredictable results. HTH
Erik Moore
Clientelligence
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform