Wiki Home

Vfe Bo Tree


Namespace: B2B
Used at runtime, creates a visual layout of how BO's are related.

Two ways to use:

1. Run app, open form, suspend, ^F2 (actives command windows), DO Vfe Bo Tree (don't hit enter), point mouse at form (don't click), hit Enter.

2. Put a button on your form: .click = "DO Vfe Bo Tree WITH thisform.oPresentObj.oBizObj"


* VfeBoTree.prg 
* creates a treeview of VFE BO's
* Pass a VFE BizObject 
* or point the mouse at a VFE form an this will try and find the main BO (point, then call this)

LPARAMETERS ;
	toBo

RELEASE goOtForm
PUBLIC goOtForm

LOCAL ;
	loVfeThing, ;
	loBO
	
IF VARTYPE( toBO ) = "O"
	loBo = toBo
else
	* If no parameter was passed, find a BO based on what the mouse is over
	loVfeThing = SYS(1270)
	DO WHILE loVfeThing.BaseClass <> 'Form'
		loVfeThing = loVfeThing.parent
	ENDDO
	loBo = loVfeThing.oPresentObj.oBizObj
ENDIF 
	
goOtForm = CREATEOBJECT( "cForm", loBO )

RETURN

DEFINE CLASS cForm as Form

	PROCEDURE init( toBO )

		WITH this
			
			.show()
			
			.AddObject('cmdCancel', 'cCancel' )
			.cmdCancel.visible = .t.
			
			.AddObject('tree1', 'olecontrol', 'COMCtl.treectrl')
			WITH .tree1
				.visible = .t.
				.height = thisform.height - 35
				.width = thisform.width - 20
			ENDWITH 
		ENDWITH 

		this.xBoTree( toBO, thisform.tree1 )

		RETURN

	endproc
	
	FUNCTION xBoTree( toBo, toTree, toParent )

		LOCAL ;
			lcKey, ;
			loNode, ;
			loBo

		lcKey = SYS(2015)
		IF VARTYPE( toParent ) = "O"
			toTree.Nodes.Add( toParent, 4, lcKey, toBo.name )
		ELSE
			toTree.Nodes.Add( , , lcKey, toBo.name )
		ENDIF
		loNode = toTree.Nodes.item[lcKey]

		IF PEMSTATUS( toBo, "oBizObjs", 5 )  && do I need this?
			FOR EACH loBo IN toBo.oBizObjs.item
				this.xBoTree( loBo, toTree, loNode )
			ENDFOR
		ENDIF

		loNode.EnsureVisible()
		loNode.Expanded = .t.

		return

	ENDPROC 		


ENDDEFINE 
	
DEFINE CLASS cCancel as CommandButton 
	CANCEL = .t.
	caption = "Cancel"
	PROCEDURE init
		this.Height = 25
		this.Top = thisform.height - this.Height - 5
		this.left = thisform.width - this.Width - 5
	endproc
	PROCEDURE click
		thisform.release
	ENDPROC
ENDDEFINE 

Contributors Carl Karsten
Category Visual FoxExpress Category Code Samples