Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Keypress ESC
Message
De
09/04/2003 21:20:12
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
09/04/2003 21:07:19
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00775837
Message ID:
00775847
Vues:
21
>hi hilmar,
>
>thanks..
>
>i have a close button in my form, so i will set the property cancel to .T.
>
>but im just curious, how do i do that in my form keypress?

I am not so sure about all the details, right now. Basically, I think you have to check whether the key pressed is "ESC" - you will have to look up the code for that. This is the same code you find in the help topic for INKEY(). For ESC, that is number 27.

I understand you would need to set Form.KeyPreview to .T., so that the form sees the keys pressed before the controls contained in the form. (Otherwise, the form doesn't see the keys pressed at all.)

In summary, your code would probably look something like this:
* Method: Form.KeyPress()
lparameters nKeyCode, nShiftAltCtrl
if nKeyCode = 27
  ThisForm.MyMethodForClosingForm()
endif
If you use #DEFINE commands, you can make this more readable. In some include file, you have:
#DEFINE KEY_ESC 27
and then you can change the third line of the code above, as follows:
* Method: Form.KeyPress()
lparameters nKeyCode, nShiftAltCtrl
if nKeyCode = KEY_ESC
  ThisForm.MyMethodForClosingForm()
endif
Regards,

Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform