Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
GetMessage API Hook in Form
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00888527
Message ID:
00890283
Vues:
30
This message has been marked as a message which has helped to the initial question of the thread.
Brent,

Does the button have it's Cancel property set to .T.? If so you can change your valid:
if ( lastkey() = 27 )
   * cancel button was clicked
   return .t.
endif

* rest of the valid code goes here
But, the valid is going to trigger before QueryUnload. so there's no way of knowing that they are trying to close the form.

I pretty much avoid returning .f. from Valid because you get yourself into these sorts of catch-22 situations. Can you move your code to the TextBox.LostFocus instead?

VFP isn't like VB or C/C++ we don't really have access to these windows messages like you seem to be used to. That's good and bad. it's good because we really don't have to worry about them, VFP just handles it. It's bad if you come from another language, the key is to learn how things work in VFP. Using the event tracking feature of the debugger is a great help in figuring out event sequences like this.

You can also get rid of the titlebar Close button and the ControlMenu and force the users into clicking your cancel button to close the form and keep your code in the Textbox.Valid.

>I forgot to tell you something else important: The reason that the form does not close when the user tries closing with one of the title bar close methods is because of code I have in the VALID method of a TextBox control on the form. I will explain. There is a "Cancel" button on the form. If the user clicks that button, I do not want data in the TextBox control to be validated and, if incorrect, prevent the form's focus from leaving that TextBox. Hence, in the VALID method I have placed code that checks whether the point on the form where the user clicked is contained within the form coordinates of the "Cancel" button. If the point clicked is not part of the "Cancel" button, and the TextBox data is invalid, then the focus remains in the TextBox.
>
>I need some way of also capturing the title bar close option selections so that I can include additional code in the TextBox VALID method to test for those selections and allow the focus of the form to leave that control and allow the form to close.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform