Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
BINDEVENTS and stopping the event
Message
De
02/12/2003 21:45:56
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00855252
Message ID:
00855277
Vues:
18
Ok, I was wrong on how QueryUnload() works....I'd still use it to handle the "x" button, but it works like this
If Not this.IsOkToExit()
  NoDefault
EndIf
and it only works from the x button...

As for the event binding, the only thing I can think of that would mean the least amount of coding is this:
Add a property to the form called lIsOkToExit. It will be .T. or .F.
In your IsOkToExit() method, set the lIsOkToExit property to the return value, prior to returning it.
In the form's Release() method, check the flag and issue a NoDefault if the flag is .F.
e.g.
**---- IsOkToExit()
** determine if it's ok here **

this.lIsOkToExit=llOK
Return llOK


**---- Release()
If Not this.lIsOkToExit
  NoDefault
EndIf
If you use the QueryUnload() keep it pointing to the IsOk() method and not the flag.

>Trey,
>Thanks for the answer. I was using this case as an example. The IsOkay() method is being bound to many different controls on the form. Any thoughts? I don't really want to write and maintain a check like the one you described in several places. Thanks again,
>
>jfh
>
>>>Hello,
>>>Lets say I have a piece of code that returns .T. or .F. depending on if it is okay to close a form or not. Now, the exit button on the form just calls the forms release method. So, I bind the click of the button to the IsOkToExit method on the form. The method, in this case, returns .F., how to I halt the execution of the button's code? Thanks,
>>>
>>>jfh
>>
>>I wouldn't bind the event in this case.
>>
>>You could wrap the call, e.g.
>>
>>
** exit button's Click() event
>>If thisform.IsOkToExit()
>>  thisform.Release()
>>EndIf
>>
>>My preferred way of doing this is to put the IsOkToExit call in the form's QueryUnload(), then, even if the user clicks the 'x' to close the form it still halts the release, e.g.
>>
>>just call the release in the button click
>>
** exit button's Click() event
>>thisform.Release()
>>and let the QueryUnload() handle the exit approval
>>
** QueryUnload()
>>Return thisform.IsOkToExit()
>>
>>
>>If the QueryUnload() returns .F., the form release is halted.
Insanity: Doing the same thing over and over and expecting different results.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform