Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VALID() and the Cancel Button
Message
 
À
02/04/1998 10:12:55
Rex Mahel
Realm Software, Llc
Ohio, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00088942
Message ID:
00088948
Vues:
32
>All,
>
>This has been a problem forever, but mayby someone has a new idea. How do you code Valid clauses to allow the user to press a Cancel button and not have to validate the current field (VFP5.0)? I hope there is a method or event which fires after the mousepress but before the Valid.
>
>Any ideas?
>
>Thanks
>
>Rex

There was an article "PEM for your base classes" by Doug Hennig in February's 1997 FoxTalk. with the solution on the base classes level for this problem.
The general idea is in using of sys(1270) which points to object under the mouse cursor. The code in Valid method from that article:
 * Valid event code
 local oObject
 oObject = sys(1270)
 if lastkey = 27 or (type('oObject') = 'O' and ;
      type('oObject.lCancel') = 'L' and oObject.lCancel)
      return .t.
 endif
 return this.Validation()
Note that commandbutton class has the custom property lCancel which determines is this button is used as Cancel button, and other classes have custom validation method which performs the validation itself.

Sometimes I use just simplified version of this, without any custom methods and properties:


* Valid event code
local oObject
oObject = sys(1270)
if lastkey = 27 or oObject.name = "MyCancelButton"
return .t.
endif

* validation code here




HTH,

Nick
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform