Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cancelling when in Valid Event
Message
 
To
13/07/1997 00:00:04
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00039722
Message ID:
00039853
Views:
46
>I am converting a Clipper application to VFP 5.0. As I am rather new to Windows programming I guess this is a rather basic question.
>
>I would like to cancel and exit my form by pressing a Cancel button. However, if i am stuck in a Valid event, i am unable to do so until i enter a valid item in the field concerned. How do i solve this problem ?
>
>Thanks
>
>DESTINE

There was an article "PEM for your base classes" by Doug Hennig in February's FoxTalk. with the solution 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