Problems with oTree ( fwh)

Problems with oTree ( fwh)

Postby Silvio.Falconi » Sun Nov 22, 2015 4:28 pm

I wish converte an old tree ( make with Goran Tree) into trre of Fivetech

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)





Image


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
Image

TREE\LIVELLO2.BMP
Image
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7048
Joined: Thu Oct 18, 2012 7:17 pm

Re: Problems with oTree ( fwh)

Postby MaxP » Wed Nov 25, 2015 5:18 pm

You perform these changes:

Code: Select all  Expand view

function BuildTree( oTree )
   local oLink1, oLink2

   SELECT GE
   GE->(DbGoTop())

      DO WHILE ! GE->(EOF())
        if Rtrim(GE->GEPClave) == ""
         oLink1 := oTree:Add(GE->GEMATERIA,0)
         oLink1:Cargo :=  Upper(GE->GEMATERIA)
         oTree:Cargo  := GE->GEMATERIA
     else
         oLink2 := oLink1:Add(GE->GEPClave,1)
         oLink2:Cargo := Upper(GE->GEMATERIA) + Upper(GE->GEPClave)
      endif
      GE->(DbSkip())
   ENDDO

   oTree:SetFocus()
   oTree:expandall()

   return nil
 


Code: Select all  Expand view

   Function LoadImagelist(oDlg)
   Local  oImageList := TImageList():New()
   Local  oBmp1 ,oBmp2
   *oBmp3 ,oBmp4


   oBmp1 := TBitmap():Define( "TREELEVEL1"   , , oDlg )
   oBmp2 := TBitmap():Define( "TREELEVEL2"   , , oDlg )

    oImageList:Add( oBmp1 )
    oImageList:Add( oBmp2 )


  Return oImageList
 


Regards
Massimo
User avatar
MaxP
 
Posts: 85
Joined: Thu Jul 12, 2007 2:02 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 55 guests