Page 1 of 1

Treeview question

Posted: Wed Nov 30, 2005 8:47 pm
by wpacheco
Hi guys

I'm working in a Treeview control and don't find the way to show the dots lines and (+) (-) sign. There is no problem with the items brance neither bitmaps only the dots.

Any suggest?

Thanks

Williams

Posted: Thu Dec 01, 2005 9:52 am
by Antonio Linares
Williams,

You may review samples\TreeView.prg and samples\TestTree.prg. In both samples a treeview is used and the [+], [-] and dotted lines are shown.

Posted: Thu Dec 01, 2005 8:21 pm
by wpacheco
Thanks Antonio

You're right but the samples show a control from code not from resource. I don't know if this could be the problem. I've set up a SysTreeView32 control on this way from RWS

CONTROL "", 1007, "SysTreeView32", WS_CHILD | WS_VISIBLE | WS_BORDER, 12, 72, 206, 100

and my code is

Code: Select all

define dialog oDlg of oWChild resource "nomdepto" font oCfg:aFonts[1]

oImageList := TImageList():New( 0, 0 )
oTree := TTreeView():Redefine( 1007, oDlg )
oTree:bChanged = { || ChkTreeItem( oTree:GetSelected(), oNomDep ), ;
		                      ChgCtrlMode( oGet, "REFRESH" ) }

activate window oWChild valid on init FillTree( oTree, oImageList, oNomDep )
// --------------------------------------------------------
function FillTree( oTree, oImageList, oNomDep )
	local cCodigo, lFirst := .t.
	local cOrder := oNomDep:SetOrder( "codigo" )

	oTree:SetImageList( oImageList )
	do while !oNomDep:Eof()
		if lFirst
			cCodigo := AllTrim( oNomDep:nomdepcod )
			lFirst := .f.
		endif

		if Len( AllTrim( oNomDep:nomdepcod )) == Len( cCodigo )
			oTree:Add( AllTrim( oNomDep:nomdepcod ) + " - " + AllTrim( oNomDep:nomdepnom ), 0 )
		endif
		oNomDep:Skip()
	enddo
	oNomDep:SetOrder( cOrder )
	
return nil
// --------------------------------------------------------
function ChkTreeItem( oItem, oNomDep, oGet )
	local cCodigo := AllTrim( StrToken( oItem:cPrompt, 1, "-" ))
	local cOrder := oNomDep:SetOrder( "codigo" )
	local nPos

	oNomDep:Seek( cCodigo )
	nPos := oNomDep:RecNo()
	if Len( oItem:aItems ) = 0
		oNomDep:Skip()
		cRoot := AllTrim( oNomDep:nomdepcod )
		if !oNomDep:Eof()
			do while !oNomDep:Eof()
				if Left( oNomDep:nomdepcod, Len( cCodigo )) == cCodigo .and. ;
				   Len( AllTrim( oNomDep:nomdepcod )) = Len( cRoot )
					oItem:Add( AllTrim( oNomDep:nomdepcod ) + " - " + AllTrim( oNomDep:nomdepnom ))
				endif
				oNomDep:Skip()
			enddo
		endif
	endif
	oNomDep:GoTo( nPos )
	oNomDep:Load()
	oItem:Expand()
return nil

so as I say before, the grid work ok, every brance works fine. If I define bitmaps on the oImageList object this shows ok... the only thing is the lines dots. Take in mind that the database object was defined ok and working... just I don't put code about it for compact the sample

Thanks

Posted: Fri Dec 02, 2005 4:07 pm
by wpacheco
Dear friends:

After look several samples, finally I found the solution to the (+)/(-) bitmaps and dotlines. When you defined an SysTreeView32 control on a DLL or .RC file, you should set the constant number 135 or 7 in the control style box

Code: Select all

CONTROL "", 1007, "SysTreeView32", WS_CHILD | WS_VISIBLE | 135 | WS_BORDER, 12, 72, 206, 100
The another tip is fill the tree in the ON INIT event of your dialog activation. After that you Tree control should look fine :wink:

Posted: Fri Dec 02, 2005 8:07 pm
by Antonio Linares
Williams,

Many thanks for your feedback,

Posted: Fri Dec 02, 2005 8:10 pm
by Sakis
Hi Again Williams

Since now accomplished to decomapile the dll. I post here the results for you or enyone who want this info.

Try the following:

Code: Select all

CONTROL "", 4008, "SysTreeView32", TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 402, 195, 225, 150 , 0x00020200
Regards from Greece :D
Dionisis