Whith the Big Help of Mr Rao I made a little test to showa tree into xbrowse where each level have a different images
the test showed many labotaories of my school and for each laboratory you can show the component sample : computer,printers,mouse..
Now the problem is this : if I have many categories how I can make it ? I must rewrite the function when I have a new component ?
I thinked to create an extern dbf to insert all categories and his bitmaps and the show all into the xbrowse tree.
To resolve the problem I made a dbf ( table.dbf with 4 field : code, cvetab,descri, image) and the I create two array from this archive :
aItems where I insert all names
ahardBmp where I insert all images
USE TABLE ALIAS TABLE
INDEX ON TABLE->CODE TO CODETABLE
TABLE->(DbSeek("H"))
DO WHILE TABLE->CveTab="H" .AND. !TABLE->(EoF())
AAdd(aItems,TRIM(TABLE->DESCRI))
AAdd(ahardBmp,TABLE->Bitmap)
TABLE->(DbSkip())
ENDDO
TABLE->(DbCloseArea())
I try with this code but it not run ok
It not run ok I t show for all level only TREE_AULE.bmp
Someone can Help me please ?
the test showed many labotaories of my school and for each laboratory you can show the component sample : computer,printers,mouse..
Now the problem is this : if I have many categories how I can make it ? I must rewrite the function when I have a new component ?
I thinked to create an extern dbf to insert all categories and his bitmaps and the show all into the xbrowse tree.
To resolve the problem I made a dbf ( table.dbf with 4 field : code, cvetab,descri, image) and the I create two array from this archive :
aItems where I insert all names
ahardBmp where I insert all images
USE TABLE ALIAS TABLE
INDEX ON TABLE->CODE TO CODETABLE
TABLE->(DbSeek("H"))
DO WHILE TABLE->CveTab="H" .AND. !TABLE->(EoF())
AAdd(aItems,TRIM(TABLE->DESCRI))
AAdd(ahardBmp,TABLE->Bitmap)
TABLE->(DbSkip())
ENDDO
TABLE->(DbCloseArea())
I try with this code but it not run ok
#include "FiveWin.ch"
#include "xbrowse.ch"
function Main()
local oWnd, oBrw ,oBold
local ahardBmp:={}
local aItems :={}
USE TABLE ALIAS TABLE
INDEX ON TABLE->CODE TO CODETABLE
TABLE->(DbSeek("H"))
DO WHILE TABLE->CveTab="H" .AND. !TABLE->(EoF())
AAdd(aItems,TRIM(TABLE->DESCRI))
AAdd(ahardBmp,TABLE->Bitmap)
TABLE->(DbSkip())
ENDDO
TABLE->(DbCloseArea())
USE HARDWARE
INDEX ON Field->LABORATORY TO LABS
SET ORDER TO "LABS"
GO TOP
DEFINE FONT oBold NAME "TAHOMA" SIZE 0,-12 BOLD
DEFINE WINDOW oWnd TITLE "SAMPLE DBF shown as a tree with XBrowse width images"
@ 2, 0 XBROWSE oBrw OF oWnd LINES CELL
oBrw:SetTree( BuildTree(), {"TREE_LAB", "TREE_AULE", 'TREE_HARD' } )
WITH OBJECT oBrw:aCols[ 1 ]
AEval(ahardBmp, { |cBmpFile| (oCol:AddBmpFile(cBmpFile))} )
:bBmpData := { || If( oBrw:oTreeItem:oTree == nil, ;
AScan( aItems, Trim( oBrw:oTreeItem:cPrompt ) ) + 2, ;
If( oBrw:oTreeItem:lOpened, 1, 2 ) ) }
END
ADD TO oBrw DATA oBrw:oTreeItem:Cargo[ 1 ] HEADER "MARCA"
ADD TO oBrw DATA oBrw:oTreeItem:Cargo[ 2 ] HEADER "MODELLO"
ADD TO oBrw DATA oBrw:oTreeItem:Cargo[ 3 ] HEADER "NUM INVENTARIO"
oBrw:CreateFromCode()
oBrw:aCols[ 1 ]:cHeader = "LABORATORY HARDWARE TYPE"
oWnd:oClient = oBrw
ACTIVATE WINDOW oWnd
return nil
static function BuildTree()
local oTree, cState
TREE oTree
while ! Eof()
if Empty( cState )
_TreeItem( HARDWARE->LABORATORY ):Cargo := { Space( 20 ), Space( 20 ), Space( 20 ) }
TREE
cState = HARDWARE->LABORATORY
else
if cState != HARDWARE->LABORATORY
ENDTREE
cState = HARDWARE->LABORATORY
_TreeItem( HARDWARE->LABORATORY ):Cargo := { Space( 20 ), Space( 20 ), Space( 20 ) }
TREE
endif
endif
if HARDWARE->LABORATORY == cState
_TreeItem( HARDWARE->Type ):Cargo := { HARDWARE->marca, HARDWARE->modello, HARDWARE->CODICE }
endif
SKIP
enddo
ENDTREE
ENDTREE
GO TOP
return oTreeIt not run ok I t show for all level only TREE_AULE.bmp
Someone can Help me please ?
Best Regards, Saludos
Falconi Silvio
Falconi Silvio