and I use a dbf with only two field
DbCreate('GE', {{'GEMATERIA' , 'C', 40, 0} ,;
{'GEPCLAVE' , 'C', 45, 0} }, 'DBFCDX')
the oTree run ok but I not understood How run the images because I not see the imae at level right ,Someone can help me please ? ( thanks)
My test
- Code: Select all Expand view
#include "fivewin.ch"
#include "constant.ch"
//#include "treeview.ch"
#include "wcolors.ch"
Static oTree,oImageList
Function Test()
Local oDlg,oTree
Local nBottom := 20
Local nRight := 52
Local nWidth := Max( nRight * DLG_CHARPIX_W, 180 )
Local nHeight := nBottom * DLG_CHARPIX_H
lOCAL oBtnAceptar, oBtnCancel
LOCAL cMateria :=""
local lok:=.f.
USE GRUENT ALIAS GE
INDEX ON UPPER(GE->GEMATERIA)+UPPER(GE->GEPCLAVE) TAG GE01 FOR !Deleted()
INDEX ON UPPER(GE->GEMATERIA) TAG GE02 FOR ((!DELETED()) )
DEFINE DIALOG oDlg ;
TITLE "Test Tree" ;
SIZE nWidth, nHeight PIXEL ;
STYLE nOr( DS_MODALFRAME, WS_POPUP, WS_CAPTION, 4 )
oTree = TTreeView():New( 2, 0, oDlg,,,, , 150, 120)
oTree:OnClick = { || FrClickTree( oTree ) }
@ 120, 155 BUTTON oBtnAceptar PROMPT "&Conferma" ;
SIZE 48, 10 PIXEL OF oDlg ;
ACTION oDlg:End()
@ 134, 155 BUTTON oBtnCancel PROMPT "&Annulla" ;
SIZE 48, 10 PIXEL OF oDlg ;
ACTION oDlg:End()
/* oDlg:bInit := { || (oImageList:=LoadImagelist(oDlg),;
BuildTree( oTree ),;
oTree:SetImageList( oImageList ) ) } */
ACTIVATE DIALOG oDlg CENTERED ;
ON INIT (oImageList:=LoadImagelist(oDlg),;
BuildTree( oTree ),;
oTree:SetImageList( oImageList ) )
return nil
//---------------------------------------------------------------------------------------------------//
static function FrClickTree( oTree )
local oLink := oTree:GetSelected
local cPrompt := oLink:cPrompt
msginfo(cPrompt)
return nil
//---------------------------------------------------------------------------------------------------//
function BuildTree( oTree )
local oLink1, oLink2
SELECT GE
GE->(DbGoTop())
DO WHILE ! GE->(EOF())
if Rtrim(GE->GEPClave) == ""
oLink1 := oTree:Add(GE->GEMATERIA,1)
oLink1:Cargo := Upper(GE->GEMATERIA)
oTree:Cargo := GE->GEMATERIA
else
oLink2 := oLink1:Add(GE->GEPClave,2)
oLink2:Cargo := Upper(GE->GEMATERIA) + Upper(GE->GEPClave)
endif
GE->(DbSkip())
ENDDO
oTree:SetFocus()
oTree:expandall()
return nil
//-----------------------------------------------------------------------------------------------------//
Function LoadImagelist(oDlg)
Local oImageList := TImageList():New()
Local oBmp1 ,oBmp2
*oBmp3 ,oBmp4
oBmp1 := TBitmap():Define( "TREELEVEL2" , , oDlg )
oBmp2 := TBitmap():Define( "TREELEVEL1" , , oDlg )
oImageList:Add( oBmp1, oBmp2 )
Return oImageList
//-----------------------------------------------------------------------------------------------------//
my test.rc
- Code: Select all Expand view
1 24 "WindowsXP.Manifest"
TREELEVEL1 BITMAP ".\TREE\LIVELLO1.bmp"
TREELEVEL2 BITMAP ".\TREE\LIVELLO2.BMP"
my images
TREE\LIVELLO1.bmp
TREE\LIVELLO2.BMP