After the last sample I try to insert another component but I think I must use another archive to insert the hardaware type because I have many component to insert :
Computer
Monitor
Keyboard
Mouse
Printer
Swicth
Scanner
Camera
Projector
the code
- Code: Select all Expand view
- function Main()
local oWnd, oBrw ,oBold
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' } )
oBrw:lKinetic = .F.
WITH OBJECT oBrw:aCols[ 1 ]
:AddResource( 'TREE_LAPTOP' )
:AddResource( 'TREE_PRINTERS' )
:AddResource( 'TREE_MONITOR' )
:AddResource( 'TREE_KEYBOARD' )
:AddResource( 'TREE_SWITCH' )
:AddResource( 'TREE_MOUSE' )
:AddResource( 'TREE_POCKET' )
:AddResource( 'TREE_SCANNER' )
:bBmpData := { || If( oBrw:oTreeItem:oTree == nil, ;
HB_DeCode( Trim( oBrw:oTreeItem:cPrompt ), 'NOTEBOOK', 4, 'PRINTERS', 5, ;
(HB_DeCode( Trim( oBrw:oTreeItem:cPrompt ), 'MONITOR', 6, 'KEYBOARD', 7, ;
(HB_DeCode( Trim( oBrw:oTreeItem:cPrompt ), 'SWITCH', 8, 'MOUSE', 9, ;
(HB_DeCode( Trim( oBrw:oTreeItem:cPrompt ), 'POCKET', 10, 'SCANNER', 11, ;
3)))))) ), ;
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:lFooter := .t.
oBrw:nMarqueeStyle = MARQSTYLE_HIGHLROW
oBrw:nStretchCol = STRETCHCOL_LAST
oBrw:nRowHeight :=40
oBrw:nHeaderHeight := 36
oBrw:nRowDividerStyle := 0
* oBrw:nColDividerStyle := 0
// If different fonts are required on the basis of oItem:nLevel
AEval( oBrw:aCols, { |oCol| oCol:oDataFont := { || If( oBrw:oTreeItem:nLevel == 1, oBold, oBrw:oFont ) } } )
ntotal:= (alias())->(OrdKeyCount())
oBrw:aCols[ 1 ]:cFooter := "Total"
oBrw:aCols[ 2 ]:cFooter := ntotal
AEval( oBrw:aCols, { |oCol| oCol:oFooterFont := oBold } )
oBrw:MakeTotals()
oBrw:CreateFromCode()
oBrw:aCols[ 1 ]:cHeader = "LABORATORY HARDWARE TYPE"
oWnd:oClient = oBrw
// Create ButtonBar
BtnBar( oBrw ) // Commn ButtonBar for all sample Browses
DEFINE BUTTON OF oWnd:oBar ;
RESOURCE "EXPAND" TOP PROMPT "Expand" ;
ACTION ( oBrw:oTree:Expand(), oBrw:Refresh(), oBrw:SetFocus() )
DEFINE BUTTON OF oWnd:oBar ;
RESOURCE "COLLAPS" TOP PROMPT "Collapse" ;
ACTION ( oBrw:oTree:Collapse(), oBrw:Refresh(), oBrw:SetFocus() )
SET MESSAGE OF oWnd TO oWnd:cCaption 2007
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 oTree
as you can see on this picture
I add a code but I thinked perhaps there is another method or we can insert another dbf component.dbf ( code, description, images)
How I can make ?