Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VALID() and the Cancel Button
Message
 
To
02/04/1998 10:12:55
Rex Mahel
Realm Software, Llc
Ohio, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00088942
Message ID:
00088948
Views:
33
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform