Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Help with SetFocus
Message
De
08/12/1998 15:48:54
 
 
À
08/12/1998 15:44:50
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Divers
Thread ID:
00165152
Message ID:
00165299
Vues:
18
>Thanks for all of the help. I knew that I would need to set the Page focus first and finally came up with the following routine. You pass it an OBJECT and it should Set Focus to it no matter where it is on the form.
>
>My original need was to Run all Valid Methods upon EXIT or SAVING. I had written a method that uses recursion to go through all objects on the form and run their VALID methods. It would return a False on the first one that did not Validate.
>
>When I got to the Object that didn't Validate, it was easy to run it's SetFocus, only it didn't work if it was embedded in one or more pageframes.
>
>The following takes the object and gets it's Hierarchy and then breaks that down looking for Pages, set focus to each in turn and then set focus to the original passed object.
>
>One Note, I had to change the first object in the Hierarchy to "THISFORM" for it to work??? go figure
>
>Thanks again, Tim
>
>
>========= GLOBAL SET FOCUS ===========
>PARAMETERS oObj
>
>IF TYPE("oObj") <> "O"
> RETURN
>ENDIF
>
>* Get Complete Object Name
>cSetFocus = SYS(1272, oObj)
>
>* Change the Form Name to THISFORM
>cSetFocus = "ThisForm" + SUBSTR(cSetFocus,AT(".",cSetFocus))
>
>cCurObj = ""
>cdot = ""
>cLeftOver = cSetFocus
>
>DO WHILE .T.
> IF (AT(".",cLeftOver ) = 0)
> EXIT
> ENDIF
>
> cCurObj = cCurObj + cdot + SUBSTR(cLeftOver ,1,AT(".",cLeftOver )-1)
> cLeftOver = SUBSTR(cLeftOver ,AT(".",cLeftOver )+1)
>
> IF TYPE("&cCurObj") = "O"
> cBaseClass = UPPER(&cCurObj..BaseClass)
> IF cBaseClass=="PAGE"
> * SetFocus to this Page before going further
> &cCurObj..SetFocus()
> ENDIF
> ENDIF
> cdot = "."
>ENDDO
>
>&cSetFocus..SetFocus()
>
>ThisForm.Refresh()
>
>RETURN

Tim, it could be a little bit simpler:
cSetFocus = SYS(1272, oObj)
&cSetfocus..Parent.Setfocus
&cSetFocus..Setfocus
Edward Pikman
Independent Consultant
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform