Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Drilling Down to Objects
Message
De
19/10/2001 21:27:03
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00570451
Message ID:
00571238
Vues:
67
>Thanks for the input Dragan.
>
>The reason I am looking at this is I am using a non-visual class to do my validation for each object on a form. Each form has a validation class, the valid event of each object calls its appropriate validation method within the class and the save button calls a general method to validate every field. Unfortunately, setting focus to a particular object is something I do not have figured out. Thus the question.
>
>I thought of using an array to hold the objects but felt it was more trouble than its worth. Cycling (Drilling Down) through the collection of objects calling the validation method for each object seems like an approach with some merit.

It's not that much of a hassle. You'd need a recursive method to drill through the objects, and in case any object's baseclass is one of Container, Grid, Page, Pageframe, ... well, here's my RegObj method:
Lpara tObj, cParentSort
If vartype(cParentSort)#"C"
	cParentSort=''
Endif
Local cSort, i
cSort=cParentSort
if type('tObj.tabindex')='N'
	cSort=cSort+right(tran(tObj.tabindex,"@0"),4)
endif
* rekurzija, vidi pod rekurzija.
Do case
	Case type("tObj.say")="L"    && do your changes here
		If type("tobj.value")#"U"    && and here
			tek=tek+1
			Dime this.tabf[tek,2]
			This.tabf[tek,1]=cSort
			This.tabf[tek,2]=tObj
		Endif
* the above check means we don't register labels, shapes etc.
	Case inlist(lower(tObj.baseclass), "pageframe")
		Local i
		For i=1 to tObj.pagecount
			cSort=cSort+ right(tran(i,"@0"),4)
			This.regobj(tObj.pages[i], cSort)
		Endfor
	Case inlist(lower(tObj.baseclass), "container")
		Local i
		For i=1 to tObj.controlcount
			This.regobj(tObj.controls[i], cSort)
		Endfor
	Case inlist(lower(tObj.baseclass), "page","column")
		Local i
		For i=1 to tObj.controlcount
			This.regobj(tObj.controls[i], cSort)
		Endfor
	Case inlist(lower(tObj.baseclass), "grid")
		Local i
		For i=1 to tObj.columncount
			cSort=cSort+ right(tran(i,"@0"),4)
			This.regobj(tObj.columns[i], cSort)
		Endfor
Endc
In form's .init, this is all it takes:
Private tek
Dime This.tabf[1,2]    && has to exist or should be addobject()ed.
tek=0

For i=1 To This.ControlCount
	loObj=This.Controls[i]
	This.RegObj(loObj)
Endfor
=Asort(This.tabf, 1)
Checking for .say property is the way I know if I got an object from one of my control classes. You'd probably check for PemStatus(tObj, "valid", 5) instead. Of course, in the form's destroy,
For i=1 to alen(this.tabf,1)
	If TYPE("this.tabf[i,2]")="O" AND not isnull(this.tabf[i,2])
		With this.tabf[i,2]
			If pemstatus(.class, 'destroy',5)
				.destroy
			Endif
		Endw
	Endif
*		this.tabf[i,2]=null
Endfor
This.tabf=.f.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform