Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do I make ESCAPE close a form
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00397900
Message ID:
00397942
Vues:
11
>How do I make the ESCape key close a form? I suppose I could put an invisible button on the form with escape as the default. Is that the best way. I tried to use ON ESCAPE but couldn't get it to work.

Create a CommandButton and set it's Cancel property to .T. - the Click() event will fire for the Control. Note that the Valid and LostFocus events of whatever control is currently in Focus will fire; you may want to alter you Valid() code to check to see if the Cancel action was triggered. Also realize that the Escape may not fire immediately; VFP doesn't process the pending keyboard event until it looks at the Windows message queue - in long, compute-intensive operations, or in a single routine that makes no UI references and never makes a call to another method, function or procedure, VFP generally won't look - making calls to DOEVENTS() will force VFP to process pending events. DOEVENTS() has a noticable impact on performance; call it at intermittent intervals inside a tight loop rather than on each pass should be adequate, and prevents the user from thinking that the app has 'locked up'. VFP can only check for events between lines of code, so single statements that need a long time to complete will have the same behavior; adding a reference to a UDF() that updates a progress bar or calls DOEVENTS() give the event handler a chance to fire, with the obvious cost of overhead.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform