How To Get Bitmap In Tree

How To Get Bitmap In Tree

Postby acwoo1 » Tue May 08, 2012 4:17 am

Hi

Code: Select all  Expand view
Function main()

#Include "FiveWin.ch"


   LOCAL oDlg, oTree, oImageList
   local oFont
   local cDirect1:= space(40)

   DEFINE FONT oFont NAME "Arial" SIZE 0, -11

        DEFINE DIALOG oDlg FROM 0, 0 TO 26, 79 ;
        TITLE "Test Tree"  COLOR CLR_BLACK, RGB( 196, 244, 244 )


   oImageList = TImageList():New()
   oImageList:Add( TBitmap():Define( , "folder.bmp",, oDlg ), ;        // nImage == 0 (default if not specified)
                   TBitmap():Define( , "fldMask.bmp",, oDlg ) )
   oImageList:Add( TBitmap():Define( , "form.bmp",, oDlg ), ;          // nImage == 1
                   TBitmap():Define( , "frmMask.bmp",, oDlg ) )
   oImageList:Add( TBitmap():Define( , "icon.bmp",, oDlg ),;           // nImage == 2
                   TBitmap():Define( , "icoMask.bmp",, oDlg ) )
   oImageList:Add( TBitmap():Define( , "bitmap.bmp",, oDlg ),;         // nImage == 4
                   TBitmap():Define( , "bmpMask.bmp",, oDlg ) )

   @ 0.25, 0.5 TREEVIEW oTree OF oDlg SIZE 306,170
   oTree:SetColor( CLR_BLACK, RGB( 196, 244, 244 ))
   oTree:bLClicked := { | nRow, nCol, nKeyFlags | MyClick1Test( nRow, nCol, oTree, cDirect1 ) }

   @ 9.95, 22.5 BUTTON "&Exit"   OF oDlg ACTION oDlg:End() SIZE 40, 12

   ACTIVATE DIALOG oDlg CENTERED ON INIT AddItems1Test( oTree, oImageList, cDirect1 )

Return NIL

********************************************************************************
Function AddItems1Test( oTree, oImageList, cDirect1 )
 
   local oItem1, oItem2, oItem3
   local lItem1a:= .t., lItem2a:= .t., lItem3a:= .t.

   oTree:SetImageList( oImageList )
 
   oItem1 = oTree:Add( "Personnel", 1 )

     oItem11 = oItem1:Add( "Add",   6) ; oItem11:Cargo:={"Personnel", 1}
     oItem111 = oItem11:Add( "Add Item 1a", 6) ; oItem111:Cargo:={"Personnel", 11}
     oItem112 = oItem11:Add( "Add Item 1b", 6) ; oItem112:Cargo:={"Personnel", 12}
     oItem1121 = oItem112:Add( "Add Item 1b1", 6) ; oItem1121:Cargo:={"Personnel", 121}
     oItem1122 = oItem112:Add( "Add Item 1b2", 6) ; oItem1122:Cargo:={"Personnel", 122}
     oItem12 = oItem1:Add( "View",   6) ; oItem12:Cargo:={"Personnel", 2}
     oItem13 = oItem1:Add( "Edit", 6) ; oItem13:Cargo:={"Personnel", 3}


   oTree:Expand()

Return NIL

********************************************************************************
Function Myclick1Test( nRow, nCol, oTree, cDirect1 )


   local oItem, array, Mydate, Mget, hItem, II, oItemRadio

   oItem := oTree:HitTest( nRow, nCol )

   IF oItem != NIL
      IF oItem:Cargo != NIL      
         array := oItem:Cargo
         DO CASE
           CASE array[1] = "Personnel"
              if array[2] = 11
                   msginfo(" Item 1a")
              elseif array[2] = 12
                   msginfo(" Item 1b")
              elseif array[2] = 121
                   msginfo(" Item 1b1")
              elseif array[2] = 122
                   msginfo(" Item 1b2")
              elseif array[2] = 2
                   msginfo(" Item 2")
              elseif array[2] = 3
                   msginfo(" Item 3")
              endif      
         ENDCASE
      ENDIF
   ENDIF

return nil

********************************


Not all the bitmaps above appear. How to make them appear.

Regards

ACWoo
Using FWH1201+bcc582+Harbour
acwoo1
 
Posts: 173
Joined: Tue Nov 10, 2009 10:56 am

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 99 guests