Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is there an event that traps focus changing on a form?
Message
De
09/12/2009 19:33:51
 
 
À
09/12/2009 16:43:32
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Database:
Visual FoxPro
Divers
Thread ID:
01438293
Message ID:
01438310
Vues:
82
>Say that I have a method on my form that I want to fire every time the user tabs out of one textbox and into the next. Or when they click on some other control on the form to change focus of that control....
>
>So I'm looking for a way to fire this method as bascially any time focus changes on the form, but I do not want to add code to EVERY control's LostFocus() event.
>
>Any ideas?
>
>The reason for this is I need to run some calculations based on the inputs values of several textboxes, and I want it to fire every time they tab out of a textbox so I can update the data that I display on the form in other textboxes.

Basic concept:
Add a property to the form named OLastFocusControl.
In each type of control's GotFocus (you are subclassing controls, of course..) --
(1) IF VARTYPE(Thisform.OLastFocusControl)="O", do your calculations.
(2) Then set Thisform.oLastFocusControl = THIS if the control is a data control or = NULL if it is a non-data control (i.e., command button).

BTW, I rely on this basic approach for my validation -- because sometimes my validation depends on not only which control the user just came from, but also which control has focus now. This approach also makes it easy for me to issue WAIT WIND NOWAIT warnings for invalid entries while letting the user continue to move freely around the form, and then hard-trap the error and display a dialog box if the user attempts to save a record with invalid data.

-mark
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform