Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Supported interfaces in live object
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00391907
Message ID:
00392188
Vues:
10
>Mike,
>Could you start adding the < pre >< /pre > tag around your code. You have >indentation, we'd like to see it. *s*

Indentation? Oh, I suppose you're going to start in about readability and all that, huh? :-) Alright, here ya go:
LPARAMETERS NODE

*-- Enable the Stop button
ThisForm.cmdStop.Enabled = .T.

liCounter = 0 && local child object counter for DOEVENTS

*-- Initialize objects
oADSobj = NULL
oCurrentADSobj = NULL

oADSobj = GETOBJECT(ALLTRIM(THISFORM.Text1.VALUE))
oCurrentADSobj = GETOBJECT(gsPath)

IF THISFORM.Treeview1.Nodes.COUNT = 0  && Treeview is not initialized
	oContainer = oADSobj
	
	*-- Top-level object
	NODE = THISFORM.Treeview1.Nodes.ADD(, , oADSobj.ADSPath, oADSobj.NAME, )
	NODE.TAG = oADSobj.ADSPath+"/"+oADSobj.NAME
	NODE.SORTED = .T.
	Node.Expanded = .T.

	FOR EACH CHILD IN oContainer

		*-- This could take a while, so give the user a chance to abort
		liCounter = liCounter + 1
		IF liCounter = 50 && Check for every 50 objects
			liCounter = 0
			DOEVENTS
			IF glStop
				ThisForm.cmdStop.Enabled = .F.
				glStop = .F.
				RETURN
			ENDIF
		ENDIF

		IF llAll OR (lsUsers $ CHILD.CLASS ;
					OR lsComputers $ CHILD.CLASS ;
					OR lsPrinters $ CHILD.CLASS ;
					OR lsGroups $ CHILD.CLASS ;
					OR lsServices $ CHILD.CLASS)

				NodeChild = THISFORM.Treeview1.Nodes.ADD(NODE, 4, , CHILD.CLASS + ": " + CHILD.NAME, )

				*-- Store the paths and object name so that we can GETOBJECT() based on information
				*-- in the node.
				NodeChild.TAG = CHILD.ADSPath
				NodeChild.SORTED = .T.

				*-- Set up an empty node in case the object is a container
				*-- Check to see if object is a container
				*-- If it is a container, add a placeholder node
				IF Child.Class <> "Schema" && Can't get the schema for a schema
					oSchema = GETOBJECT(CHILD.Schema)
				ELSE
					oSchema = .F.
				ENDIF
				IF VARTYPE(oSchema) = "O"
					IF oSchema.CONTAINER
						ChildNode = THISFORM.Treeview1.Nodes.ADD(NodeChild, 4, , "Empty",)
					ENDIF
				ENDIF  && VARTYPE(oSchema) = "O"
		ENDIF  && NOT llAll
	ENDFOR  && EACH Child IN oContainer
	THISFORM.Treeview1.Nodes(1).Expanded = .T.
ELSE
	NODE.SORTED = .T.

	*-- Check to make sure we even have an object.
	*-- If the network path is not found, oCurrentADSobj will be null.
		IF VARTYPE(oCurrentADSobj) <> "O"
		RETURN
	ENDIF
	
	*-- Check to see if object is a container
	IF oCurrentADSobj.Class <> "Schema" && Can't get the schema for a schema
		oSchema = GETOBJECT(oCurrentADSobj.Schema)
	ELSE
		oSchema = .F.
	ENDIF
	
	IF VARTYPE(oSchema) = "O"
		IF oSchema.CONTAINER
			FOR EACH CHILD IN oCurrentADSobj

				*-- This could take a while, so give the user a chance to abort
				liCounter = liCounter + 1
				IF liCounter = 50 && Check for every 50 objects
					liCounter = 0
					DOEVENTS
					IF glStop
						ThisForm.cmdStop.Enabled = .F.
						glStop = .F.
						RETURN
					ENDIF
				ENDIF	
				NewNode = THISFORM.Treeview1.Nodes.ADD(NODE, 4, , CHILD.CLASS + ": " + CHILD.NAME,)
				NewNode.TAG = CHILD.ADSPath
				NewNode.SORTED = .T.

				*-- Set up an empty node in case the object is a container
				*-- Check to see if object is a container
				*-- If it is a container, add a placeholder node
				IF Child.Class <> "Schema" && Can't get the schema for a schema
					oChildSchema = GETOBJECT(CHILD.Schema)
				ELSE
					oChildSchema = .F.
				ENDIF
				IF VARTYPE(oChildSchema) = "O"
					IF oChildSchema.CONTAINER
						NewChildNode = THISFORM.Treeview1.Nodes.ADD(NewNode, 4, , "Empty",)
					ENDIF
				ENDIF  && VARTYPE(oChildSchema) = "O"
			ENDFOR  && EACH Child in oCurrentADSobj
		ENDIF  && oSchema.Container
	ENDIF  && VARTYPE(oSchema) = "O"
ENDIF  && ThisForm.Treeview1.Nodes.Count = 0
ThisForm.cmdStop.Enabled = .F.
Mike Stewart
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform