Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What was the last object I had focus on?
Message
De
05/08/2010 16:27:45
Kevin Hickman
The Cadle Company
Ohio, États-Unis
 
 
À
05/08/2010 06:54:49
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Novell 6.x
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01475139
Message ID:
01475436
Vues:
47
why does it not recognize the baseclass for [commandbutton]? It does not seem to want to pick up on a button and when I try to add it as a baseclass I get errors when I run it.



I was wondering if there is anything internal in VFP that keeps track of the last object that had focus (kind of like the way lastkey works for the last key pressed on the keyboard), or would I have to store it in memory or a table each time I leave an object? What is the most efficient way to get this value?

Add a method called SetupSontrols() to your form and call it from the form's init(). This code in SetupCpntrols():


LPARAMETERS toObject
LOCAL loObject

*** If we have a container, drill down
IF INLIST( LOWER( ALLTRIM( toObject.BaseClass ) ), ;
[form], [pageframe], [page], [container], [grid], [column] )
FOR EACH loObject IN toObject.Objects
Thisform.SetupControls( loObject )
ENDFOR
ELSE
*** Use BindEvent to setup the Form's SetActiveControl()
*** method as the delegate for the Control's GotFocus()
IF PEMSTATUS( toObject, [ControlSource], 5 ) AND ;
PEMSTATUS( toObject, [GotFocus], 5 )
BINDEVENT( toObject, [GotFocus], Thisform, [SetActiveControl], 1 )
ENDIF
ENDIF
Add a method to the form called SetActiveControl() to your form and add this code to the method:


LOCAL laControls[ 1 ]
*** Get a Reference to the control
*** that delegated its GotFocus to this method
AEVENTS( laControls, 0 )
WITH Thisform
.oActiveControl = laControls[ 1 ]
*** Do whatever you need to do with the active control
ENDWITH
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform