Information générale
Catégorie:
Gestionnaire d'écran & Écrans
>Using VFP6 - I have a pageframe with multiple pages and each time the user changes the page I want the cursor to go to the first object on the new page. Is there any easy way of finding the first object on the page without hardcoding it?
>
>Thanks-
I read Rich and Nancy's replies but you can easily write a method to accomodate what you want. I've one called .SetFocusThisIndex(oTheContainer, nSomeTaxIndex)
and it's in my template base class making it available to all my forms.
I pass oTheContainer because this allows you to access any type of object in which form controls might be placed, including pages of a pageframe. The 2nd parameter allows more flexibility because you can choose the tabindex you need to set focus to.
.SetFocusThisIndex
LPARAMETERS roContainer, vnIndex
LOCAL i
*
* Make vnIndex 1 if not passed
*
IF PARAMETERS() < 2 OR vnIndex = 0
vnIndex = 1
ENDIF
*
* Loop through the container object and find the match.
*
WITH roContainer
FOR i = 1 TO .ControlCount
IF NOT INLIST(UPPER(.Controls[i].Class), ;
"LABEL", "CONTAINER", "SHAPE", "PAGEFRAME")
*
* Make sure it's not in above list.
*
IF PEMSTATUS(.Controls[i], "TabIndex", 5)
*
* Make sure it has a tabindex property
*
IF .Controls[i].TabIndex = vnIndex
.Controls[i].SetFocus()
ENDIF
ENDIF
ENDIF
ENDFOR
ENDWITH
This ought to do it for you.
Steve
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement