FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour From treeview Goran to fwh treeview
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
From treeview Goran to fwh treeview
Posted: Fri Sep 06, 2013 08:05 AM
Dear Friends,

I'd like use the treeview class of Fwh .
Until now I used another class of Goran Savckic.





I have these fields FrN1, FrN2, FrN3, FrN4 y Frn5

(1,0,0,0,0)
路路路(1,1,0,0,0)
路路路路路路(1,1,1,0,0)
路路路路路路(1,1,2,0,0)
路路路(1,2,0,0,0)


I have some problem to converte the funcs to use fwh treeview.


on init old app I have :
Code (fw): Select all Collapse
聽 聽 聽 聽 聽 @ 0, nSplit+2 TREE oApp():oGrid OF oApp():oDlg ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 SIZE (oApp():oDlg:nWidth())/2, (oApp():oDlg:nHeight()-22)/2 PIXEL 聽 聽;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 BITMAPS { "SH_PCLAVE","SH_MATERIA"} 聽;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 FONT oApp():oFont 聽 聽 聽 聽 聽 聽 聽 聽;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 TREE STYLE nOr( TVS_HASLINES, TVS_HASBUTTONS ) ; 
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽ON DBLCLICK FrClickTree(oApp():oGrid) 聽 ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽ON CHANGE ( oLink 聽 聽:= oApp():oGrid:GetLinkAt( oApp():oGrid:GetCursel() ) ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽xPrompt 聽:= oLink:TreeItem:cPrompt 聽,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 FR->(DbSetOrder(2)) 聽 聽 聽 聽 聽 聽 聽 聽 ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 FR->(DbSeek(UPPER(xPrompt))) 聽 聽 聽 聽,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 FR->(DbSetOrder(1)) 聽 聽 聽 聽 聽 聽 聽 聽 ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽RefreshCont(oCont,"FR") )

聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 FrTreeLoad(oApp():oGrid)





STATIC function FrTreeLoad( oTree )
聽 聽local oDatabase
聽 聽local nStep
聽 聽local oLink
聽 聽local oLink1, oLink2, oLink3, oLink4, oLink5
聽 聽local N1 := 0
聽 聽local N2 := 0
聽 聽local N3 := 0
聽 聽local N4 := 0
聽 聽// oTree:bRClicked = {|nRow,nCol| 聽MenuTree(oTree,nRow,nCol)}

聽 聽oLink := oTree:GetRoot()

聽 聽SELECT FR

聽 聽FR->(DbGoTop())

聽 聽DO WHILE ! FR->(EOF())
聽 聽 聽 if FR->FrN2 == 0
聽 聽 聽 聽 聽oLink1 := oLink:AddLastChild(FR->FrTipo,Iif(FR->FrHoja,1,2),Iif(FR->FrHoja,1,2),.t.)
聽 聽 聽 聽 聽oLink1:Cargo := Str(FR->Frn1,2)+Str(FR->Frn2,2)+Str(FR->Frn3,2)+Str(FR->Frn4,2)+Str(FR->Frn5,2)
聽 聽 聽 elseif FR->FrN3 == 0
聽 聽 聽 聽 聽oLink2 := olink1:AddLastChild(FR->FrTipo,Iif(FR->FrHoja,1,2),Iif(FR->FrHoja,1,2),.t.)
聽 聽 聽 聽 聽oLink2:Cargo := Str(FR->Frn1,2)+Str(FR->Frn2,2)+Str(FR->Frn3,2)+Str(FR->Frn4,2)+Str(FR->Frn5,2)
聽 聽 聽 elseif FR->FrN4 == 0
聽 聽 聽 聽 聽oLink3 := olink2:AddLastChild(FR->FrTipo,Iif(FR->FrHoja,1,2),Iif(FR->FrHoja,1,2),.t.)
聽 聽 聽 聽 聽oLink3:Cargo := Str(FR->Frn1,2)+Str(FR->Frn2,2)+Str(FR->Frn3,2)+Str(FR->Frn4,2)+Str(FR->Frn5,2)
聽 聽 聽 elseif FR->FrN5 == 0
聽 聽 聽 聽 聽oLink4 := olink3:AddLastChild(FR->FrTipo,Iif(FR->FrHoja,1,2),Iif(FR->FrHoja,1,2),.t.)
聽 聽 聽 聽 聽oLink4:Cargo := Str(FR->Frn1,2)+Str(FR->Frn2,2)+Str(FR->Frn3,2)+Str(FR->Frn4,2)+Str(FR->Frn5,2)
聽 聽 聽 else
聽 聽 聽 聽 聽oLink5:= oLink4:AddLastChild(FR->FrTipo,Iif(FR->FrHoja,1,2),Iif(FR->FrHoja,1,2),.t.)
聽 聽 聽 聽 聽oLink5:Cargo := Str(FR->Frn1,2)+Str(FR->Frn2,2)+Str(FR->Frn3,2)+Str(FR->Frn4,2)+Str(FR->Frn5,2)
聽 聽 聽 endif

聽 聽 聽 FR->(DbSkip())
聽 聽ENDDO





   oTree:UpdateTV()
   oTree:SetFocus()

   return nil



Someone can help me please
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 564
Joined: Thu Oct 13, 2005 09:23 AM
Re: From treeview Goran to fwh treeview
Posted: Fri Sep 06, 2013 03:16 PM
Silvio:
Code (fw): Select all Collapse
聽 聽 oApp():oTree:=TTreeView():New(0,nSplit+2,oApp():oDlg,,,.t.)// ,oApp():nWidth()/2,(oApp():nHeight()-22)/2)
聽 聽 oApp():oTree:SetColor(CLR_BLACK, CLR_WHITE)
聽 聽 oApp():oTree:bChanged := {|| ( xPrompt := oApp():oTree:GetSelected():cPrompt,;
聽聽 聽聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽FR->(DbSetOrder(2)) 聽 聽 聽 聽 聽 聽 聽 聽 ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽FR->(DbSeek(UPPER(xPrompt))) 聽 聽 聽 聽,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽FR->(DbSetOrder(1)) 聽 聽 聽 聽 聽 聽 聽 聽 ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽RefreshCont(oCont,"FR") ) }


and

Code (fw): Select all Collapse
function FrTreeLoad( oTree )
聽 聽local oLink1, oLink2, oLink3, oLink4, oLink5
聽 聽 local xPrompt
聽 聽SELECT FR
聽 聽FR->(DbGoTop())
聽 聽DO WHILE ! FR->(EOF())
聽 聽 聽 if FR->FrN2 == 0
聽 聽 聽 聽 聽oLink1 := oTree:Add(FR->FrTipo)
聽 聽 聽 聽 聽oLink1:Cargo := Str(FR->Frn1,2)+Str(FR->Frn2,2)+Str(FR->Frn3,2)+Str(FR->Frn4,2)+Str(FR->Frn5,2)
聽 聽 聽 聽 聽 聽 oTree:Cargo 聽:= FR->Frn1
聽 聽 聽 elseif FR->FrN3 == 0
聽 聽 聽 聽 聽oLink2 := oLink1:Add(FR->FrTipo)
聽 聽 聽 聽 聽oLink2:Cargo := Str(FR->Frn1,2)+Str(FR->Frn2,2)+Str(FR->Frn3,2)+Str(FR->Frn4,2)+Str(FR->Frn5,2)
聽 聽 聽 elseif FR->FrN4 == 0
聽 聽 聽 聽 聽 聽 oLink3 := oLink2:Add(FR->FrTipo)
聽 聽 聽 聽 聽oLink3:Cargo := Str(FR->Frn1,2)+Str(FR->Frn2,2)+Str(FR->Frn3,2)+Str(FR->Frn4,2)+Str(FR->Frn5,2)
聽 聽 聽 elseif FR->FrN5 == 0
聽 聽 聽 聽 聽 聽 oLink4 := oLink3:Add(FR->FrTipo)
聽 聽 聽 聽 聽oLink4:Cargo := Str(FR->Frn1,2)+Str(FR->Frn2,2)+Str(FR->Frn3,2)+Str(FR->Frn4,2)+Str(FR->Frn5,2)
聽 聽 聽 else
聽 聽 聽 聽 聽oLink5 := oLink4:Add(FR->FrTipo)
聽 聽 聽 聽 聽oLink5:Cargo := Str(FR->Frn1,2)+Str(FR->Frn2,2)+Str(FR->Frn3,2)+Str(FR->Frn4,2)+Str(FR->Frn5,2)
聽 聽 聽 endif
聽 聽 聽 FR->(DbSkip())
聽 聽ENDDO
return nil


You have to load the tree in the ON INIT clause of the dialog.

FWH Tree is easier to hanldle than Goran's one.

Regards,
Jos茅 Luis
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: From treeview Goran to fwh treeview
Posted: Fri Sep 06, 2013 06:40 PM

jos猫 , thanks so much
can we associate a bitmap for each tree .. also

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: From treeview Goran to fwh treeview
Posted: Mon Sep 09, 2013 01:34 PM

I need to Know the convertion of these lines

oTree:GetLinkAt( oTree:GetCursel() )

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: From treeview Goran to fwh treeview
Posted: Mon Sep 09, 2013 01:42 PM

oTree:GetSelected():...

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: From treeview Goran to fwh treeview
Posted: Mon Sep 09, 2013 01:51 PM
Perhaps something run but I have also many problems

for the insert level 1 (i Insert on bold the line give me errors)

local oLink := oTree:GetSelected()
local cPrompt := oLink:cPrompt
local cCargo := oLink:Cargo
local nLevel := INT(AT(" 0",cCargo)/2)
local oParent := oLink:GetParent()
local cPCargo := oLink:cargo



// a帽adir
cResto := SubStr(" 0 0 0 0 0",1,2*(5-nLevel))
oLChild := oParent:LastChild

if nLevel == 1
cNewCargo := Str(VAL(SubStr(oLChild:cargo,1,2))+1,2)+cResto
else
cNewCargo := SubStr(oLChild:Cargo,1,2*(nLevel-1))+Str(VAL(SubStr(oLChild:cargo,(2*nLevel),2))+1,2)+cResto
endif
cFaTipo := oLink:cPrompt + space(40-len(oLink:cPrompt))
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: From treeview Goran to fwh treeview
Posted: Mon Sep 09, 2013 01:58 PM

what errors ? :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: From treeview Goran to fwh treeview
Posted: Mon Sep 09, 2013 02:32 PM

Time from start: 0 hours 0 mins 3 secs
Error occurred at: 09-09-2013, 16:32:23
Error description: Error BASE/1004 Class: 'NIL' has no exported method: LASTCHILD
Args:
[ 1] = U

Stack Calls

Called from: => LASTCHILD( 0 )
Called from: source\PNewfranc.prg => FREDITA( 306 )
Called from: source\PNewfranc.prg => (b)FRANCESA2( 150 )

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: From treeview Goran to fwh treeview
Posted: Mon Sep 09, 2013 03:22 PM

Silvio,

It seems as oLink has no parent so:

oLink:GetParent()

is returning nil

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: From treeview Goran to fwh treeview
Posted: Mon Sep 09, 2013 03:46 PM

Antonio with Goran I made

local cFaTipo

local oLink := oTree:GetLinkAt( oTree:GetCursel() )
local cPrompt := oLink:TreeItem:cPrompt
local cCargo := oLink:Cargo
local nLevel := INT(AT(" 0",cCargo)/2)
local oParent := oLink:ParentLink
local oLChild
local oNewLink
local cPCargo := oParent:cargo
local cNewCargo := ""
local lFrHoja
local cResto

and I now ( for fwh tree ) I change into

local oLink := oTree:GetSelected()
local cPrompt := oLink:cPrompt
local cCargo := oLink:Cargo
local nLevel := INT(AT(" 0",cCargo)/2)
local oParent := oLink:GetParent()
local oLChild
local oNewLink
local cPCargo := oLink:cargo
local cNewCargo := ""
local lFrHoja
local cResto

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com

Continue the discussion