FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour ImageList en Treeview con Dialogo
Posts: 189
Joined: Fri Oct 14, 2005 12:33 AM
ImageList en Treeview con Dialogo
Posted: Fri Jun 16, 2006 02:50 AM
Hola a todos,

He buscado agregar un ImageList a un Treeview, pero no me funciona. Alguien sabe o ha tenido la experiencia de decirme porque no funciona este codigo?

#Include "FiveWin.ch"

Function Main()

   LOCAL oDlg, oTree, oImageList

   DEFINE DIALOG oDlg TITLE "TreeView from source"

   oImageList = TImageList():New()

   oImageList:Add( TBitmap():Define( , "..\bitmaps\16x16\folder.bmp", oDlg ),;
                   TBitmap():Define( , "..\bitmaps\16x16\fldMask.bmp", oDlg ) )
   oImageList:Add( TBitmap():Define( , "..\bitmaps\16x16\form.bmp", oDlg ),;
                   TBitmap():Define( , "..\bitmaps\16x16\frmMask.bmp", oDlg ) )
   oImageList:Add( TBitmap():Define( , "..\bitmaps\16x16\icon.bmp", oDlg ),;
                   TBitmap():Define( , "..\bitmaps\16x16\icoMask.bmp", oDlg ) )
   oImageList:Add( TBitmap():Define( , "..\bitmaps\16x16\bitmap.bmp", oDlg ),;
                   TBitmap():Define( , "..\bitmaps\16x16\bmpMask.bmp", oDlg ) )

   @ 0.5, 1 TREEVIEW oTree OF oDlg SIZE 80,60 COLOR 0, GetSysColor( 5 )

   oTree:SetImageList( oImageList )

   ACTIVATE DIALOG oDlg CENTERED ON INIT AddItems( oTree )


Return NIL

********************************************************************************
Function AddItems( oTree )
********************************************************************************
   local oItem1, oItem2, oItem3

   oItem1 = oTree:Add( "First", 0 )

            oItem1:Add( "One", 1 )
            oItem1:Add( "Two", 1 )
            oItem1:Add( "Three", 1 )

   oItem2 = oTree:Add( "Second", 0 )

            oItem2:Add( "Hello" )
            oItem2:Add( "World" )

   oItem3 = oTree:Add( "Third", 0 )

            oItem3:Add( "Last" )
            oItem3:Add( "item" )
   oTree:Expand()

Return NIL


Gracias anticipadas,
Julio Llinás
Visita mi Blog en http://mangucybernetico.blogspot.com/
xHarbour 1.1.0 + FWH810 + Borland 5.5.1
Posts: 189
Joined: Fri Oct 14, 2005 12:33 AM
ImageList en Treeview con Dialogo
Posted: Fri Jun 16, 2006 03:20 AM

Ok, Ok, Ok.... me contesto yo mismo:

Hay que pasar el oImageList a la funcion que se llama al ON INIT del dialogo, e invocar alli el metodo del treeview

oTree:SetImageList( oImageList )

.... y listo!

Perdonen, es que siempre tengo que buscar.

La pregunta ahora es: ¿De verdad que no se puede cambiar el BMP en tiempo de ejecucion? Deseo hacerlo para incluir una configuracion del sistema estilo arbol, pero debo cambiar los BMP en tiempo de ejecucion

Gracias por soportarme !

Julio Llinás
Visita mi Blog en http://mangucybernetico.blogspot.com/
xHarbour 1.1.0 + FWH810 + Borland 5.5.1
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
ImageList en Treeview con Dialogo
Posted: Fri Jun 16, 2006 08:57 AM

Julio,

Puede hacerse pero aún no esta implementado en FWH.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 205
Joined: Fri Oct 07, 2005 05:07 PM
ImageList en Treeview con Dialogo
Posted: Fri Jun 16, 2006 11:30 AM
Veams si esto resulta..
Agrega este metodo a TTVItem.prg

METHOD Set( cPrompt, nImage ) CLASS TTVItem
   DEFAULT cPrompt := ::cPrompt, ;
           nImage  := ::nImage

   TVSetTextImage( ::oTree:hWnd, ::hItem, cPrompt, nImage )

   Return nil

#pragma BEGINDUMP

#include <WinTen.h>
#include <windows.h>
#include <CommCtrl.h>
#include <ClipApi.h>

HB_FUNC ( TVSETTEXTIMAGE ) // ( hWnd ) --> cText
{
   HWND hWnd = ( HWND ) _parnl( 1 );
   HTREEITEM hItem = ( HTREEITEM ) _parnl( 2 );
   TV_ITEM tvi;
   tvi.hItem      = hItem;

   tvi.mask    = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
   tvi.pszText = _parc( 3 );
   tvi.iImage  = _parnl( 4 );
   tvi.iSelectedImage = _parnl( 4 );
   TreeView_SetItem( hWnd, &tvi );

}

#pragma ENDDUMP


Ahora puedes utilizar

oItem:Set( "MI Texto Nuevo", 2 )

ten presente que 2 es el tercer elemento en tu ImagenList, porque la numeracion comienza de 0

:-)
Saludos/regards

RenOmaS



skype: americo.balboa
Posts: 189
Joined: Fri Oct 14, 2005 12:33 AM
ImageList en Treeview con Dialogo
Posted: Mon Jun 19, 2006 12:01 AM
Muy Bien,

Pues como se muestra con el ejemplo, aquí incluyo el ejemplo que desarollé, partiendo de uno que me proporcionó AL sobre un Treeview en codigo.

Ojala y les sirva a muchos de Ustedes. Como recomendación, creo que las proximas ediciones de FW deben incluir los BMP de controles radio en BITMAPS\16x16. En este ejemplo lo hago con otros cualesquiera.

#Include "FiveWin.ch"

Function Main()

   LOCAL oDlg, oTree, oImageList
    
   // Sample suggested by Antonio Linares, and modified by Julio Llin s

   DEFINE DIALOG oDlg TITLE "TreeView from source"

   oImageList = TImageList():New()

   oImageList:Add( TBitmap():Define( , "..\bitmaps\16x16\folder.bmp", oDlg ),;
                   TBitmap():Define( , "..\bitmaps\16x16\fldMask.bmp", oDlg ) )
   oImageList:Add( TBitmap():Define( , "..\bitmaps\16x16\form.bmp", oDlg ),;
                   TBitmap():Define( , "..\bitmaps\16x16\frmMask.bmp", oDlg ) )
   oImageList:Add( TBitmap():Define( , "..\bitmaps\16x16\icon.bmp", oDlg ),;
                   TBitmap():Define( , "..\bitmaps\16x16\icoMask.bmp", oDlg ) )
   oImageList:Add( TBitmap():Define( , "..\bitmaps\16x16\bitmap.bmp", oDlg ),;
                   TBitmap():Define( , "..\bitmaps\16x16\bmpMask.bmp", oDlg ) )
   oImageList:Add( TBitmap():Define( , "..\bitmaps\16x16\folder2.bmp", oDlg ),;
                   TBitmap():Define( , "..\bitmaps\16x16\bmpMask.bmp", oDlg ) )
   oImageList:Add( TBitmap():Define( , "..\bitmaps\16x16\checkbox.bmp", oDlg ),;
                   TBitmap():Define( , "..\bitmaps\16x16\bmpMask.bmp", oDlg ) )
   oImageList:Add( TBitmap():Define( , "..\bitmaps\16x16\cancel.bmp", oDlg ),;
                   TBitmap():Define( , "..\bitmaps\16x16\bmpMask.bmp", oDlg ) )

   @ 0.5, 1 TREEVIEW oTree OF oDlg SIZE 90,60 COLOR 0, GetSysColor( 5 )

   oTree:bLDblClick := { | nRow, nCol, nKeyFlags | MyClick( nRow, nCol, oTree ) }

   ACTIVATE DIALOG oDlg CENTERED ON INIT AddItems( oTree, oImageList )

Return NIL

********************************************************************************
Function AddItems( oTree, oImageList )
********************************************************************************
   local oItem1, oItem2, oItem3
   local oItem11, oItem12, oItem13
   local oItem21, oItem22
   local oItem31, oItem32, oItem33, oItem34, oItem35
   local Mydate, Mytime

   Mydate := DATE()
   Mytime := TIME()

   oTree:SetImageList( oImageList )
  
   oItem1 = oTree:Add( "CHECKBOX in a Tree", 0 )

      // "Cargo" set a Checkbox control
      oItem11 = oItem1:Add( "One",   6); oItem11:Cargo:={"CHECKBOX"}
      oItem12 = oItem1:Add( "Two",   6); oItem12:Cargo:={"CHECKBOX"}
      oItem13 = oItem1:Add( "Three", 6); oItem13:Cargo:={"CHECKBOX"}

   oItem2 = oTree:Add( "GET in a Tree", 0 ) 

      // "Cargo" set a Get control, AND the variable to manage in GET
      oItem21 = oItem2:Add( DTOC(Mydate), 2 ); oItem21:Cargo:={"GET",Mydate}
      oItem22 = oItem2:Add( Mytime      , 2 ); oItem22:Cargo:={"GET",Mytime}

   oItem3 = oTree:Add( "RADIO in a Tree", 0 )

      // "Cargo" set a Radio control, the selected option and "parent" branch
      oItem31 = oItem3:Add( "One", 2 ); oItem31:Cargo:={"RADIO",2,oItem3}
      oItem32 = oItem3:Add( "Two", 1 ); oItem32:Cargo:={"RADIO",1,oItem3}
      oItem33 = oItem3:Add( "Tree",1 ); oItem33:Cargo:={"RADIO",1,oItem3}
      oItem34 = oItem3:Add( "Four",1 ); oItem34:Cargo:={"RADIO",1,oItem3}
      oItem35 = oItem3:Add( "Five",1 ); oItem35:Cargo:={"RADIO",1,oItem3}

   oTree:Expand()

Return NIL

********************************************************************************
Function Myclick( nRow, nCol, oTree )
********************************************************************************
   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
           // managing a checkbox control.  BMP can be changed.
           CASE array[1] = "CHECKBOX"
             IF oItem:nImage = 5
                oItem:Set( ,6)
                oItem:nImage := 6
             ELSE
                oItem:Set( ,5)
                oItem:nImage := 5
             ENDIF

           // managing a get control.  BMP can be changed.  
           //   We use MsgGet and MsgDate functions.
           //   Keep in second element of "Cargo" the variable to edit,
           //   VALTYPE of this element is important for correct GET manager
           CASE array[1] = "GET"
             DO CASE
              CASE VALTYPE( array[2] ) = "D"
                Mydate := MsgDate( array[2] )
                oItem:Set( DTOC(Mydate) )
                oItem:cPrompt := DTOC( Mydate )
                oItem:Cargo[2]:= Mydate

              CASE VALTYPE( array[2] ) = "C"
                Mget := PADR(oItem:cPrompt,256)
                IF MsgGet( "Modificar...", "Modifique esta cadena de caracteres", @Mget )
                   Mget := ALLTRIM( Mget )
                   oItem:Set( Mget )
                   oItem:cPrompt := Mget
                   oItem:Cargo[2]:= Mget
                ENDIF

              CASE VALTYPE( array[2] ) = "N"
                Mget := VAL(oItem:cPrompt)
                IF MsgGet( "Modificar...", "Modifique este numero", @Mget )
                   oItem:Set( STR(Mget) )
                   oItem:cPrompt := STR(Mget)
                   oItem:Cargo[2]:= Mget
                ENDIF

             ENDCASE

           // managing a RADIO control.  BMP can be changed
           // "2" means choosen option, and "1" means NO choosen options
           CASE array[1] = "RADIO"
             hItem := oItem:hItem
             FOR II := 1 TO LEN( array[3]:aItems )
                oItemRadio := array[3]:aItems[II]
                IF oItemRadio:hItem = hItem
                   oItemRadio:Set( ,2)
                   oItemRadio:Cargo[2]:=2
                ELSE
                   oItemRadio:Set( ,1)
                   oItemRadio:Cargo[2]:=1
                ENDIF
             NEXT
                   
         ENDCASE
      ENDIF
   ENDIF

return nil


Abrazos,
Julio Llinás
Visita mi Blog en http://mangucybernetico.blogspot.com/
xHarbour 1.1.0 + FWH810 + Borland 5.5.1
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
ImageList en Treeview con Dialogo
Posted: Mon Jun 19, 2006 04:35 AM

Julio,

>
Como recomendación, creo que las proximas ediciones de FW deben incluir los BMP de controles radio en BITMAPS\16x16.
>

Por favor, podrías enviarme esos bitmaps por email ? gracias

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1380
Joined: Fri Oct 14, 2005 01:28 PM
ImageList en Treeview con Dialogo
Posted: Fri Aug 03, 2007 10:55 PM

JLLinas;
estoy probando el código que dejaste, pero resulta que el método TTVITEM:SET() no lo tiene la clase TTVItem.
Uso la version 26MAY2005, es por eso?

gracias

Resistencia - "Ciudad de las Esculturas"

Chaco - Argentina
Posts: 1380
Joined: Fri Oct 14, 2005 01:28 PM
ImageList en Treeview con Dialogo
Posted: Tue Aug 07, 2007 01:09 AM

Antonio; tu me podrías dar algún dato sobre la consulta anterior?

gracias

Resistencia - "Ciudad de las Esculturas"

Chaco - Argentina
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
ImageList en Treeview con Dialogo
Posted: Tue Aug 07, 2007 07:20 AM

Mario,

La versión que usas es bastante antigua. Los cambios en la clase TTVItem se hicieron en octubre-Noviembre 2006.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1380
Joined: Fri Oct 14, 2005 01:28 PM
ImageList en Treeview con Dialogo
Posted: Tue Aug 07, 2007 08:11 PM

gracias

Resistencia - "Ciudad de las Esculturas"

Chaco - Argentina
Posts: 7
Joined: Tue Dec 04, 2007 07:59 PM
Error en la generacion de TTVitem.prg
Posted: Fri Feb 08, 2008 03:36 PM
Senhor Renomas , vi su post que hace algun tiempo que lo coloco pero está siendo una incognita para mi !

Tengo un problema al generar la FiveHX.lib

coloque el método "SET" en la classe TTVitem original
para cambiar el Bmp de algun item en tiempo de ejecucion

exactamente como dices tú

[red]
METHOD Set( cPrompt, nImage ) CLASS TTVItem
DEFAULT cPrompt := ::cPrompt, ;
nImage := ::nImage

TVSetTextImage( ::hWnd, ::hItem, cPrompt, nImage )

Return nil

#pragma BEGINDUMP

#include <WinTen.h>
#include <windows.h>
#include <CommCtrl.h>
#include <ClipApi.h>

HB_FUNC ( TVSETTEXTIMAGE ) // ( hWnd ) --> cText
{
HWND hWnd = ( HWND ) _parnl( 1 );
HTREEITEM hItem = ( HTREEITEM ) _parnl( 2 );
TV_ITEM tvi;
tvi.hItem = hItem;

tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
tvi.pszText = _parc( 3 );
tvi.iImage = _parnl( 4 );
tvi.iSelectedImage = _parnl( 4 );
TreeView_SetItem( hWnd, &tvi );

}

#pragma ENDDUMP
[/red]


pero en el momento que genero la lib me muestra este mensaje


[blue]
Classes - 0151 TTVITEM --------------------------------------------------------------
xHarbour Compiler build 0.99.61 (SimpLex)
Copyright 1999-2006, http://www.xharbour.org http://www.harbour-project.org/
Compiling 'c:\fwh27\source\classes\TTVITEM.prg'...

Lines 116, Functions/Procedures 5
Generating C source output to 'TTVITEM.c'...
Done.
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
ttvitem.c:
Error E2209 c:\\fwh27\\source\\classes\\TTVITEM.prg 4: Unable to open include file 'WinTen.h'
Error E2209 c:\\fwh27\\source\\classes\\TTVITEM.prg 7: Unable to open include file 'ClipApi.h'
Warning W8065 c:\\fwh27\\source\\classes\\TTVITEM.prg 11: Call to function '_parnl' with no prototype in function HB_FUN_TVSETTEXTIMAGE
Warning W8065 c:\\fwh27\\source\\classes\\TTVITEM.prg 12: Call to function '_parnl' with no prototype in function HB_FUN_TVSETTEXTIMAGE
Warning W8065 c:\\fwh27\\source\\classes\\TTVITEM.prg 17: Call to function '_parc' with no prototype in function HB_FUN_TVSETTEXTIMAGE
Warning W8069 c:\\fwh27\\source\\classes\\TTVITEM.prg 17: Nonportable pointer conversion in function HB_FUN_TVSETTEXTIMAGE
Warning W8065 c:\\fwh27\\source\\classes\\TTVITEM.prg 18: Call to function '_parnl' with no prototype in function HB_FUN_TVSETTEXTIMAGE
Warning W8065 c:\\fwh27\\source\\classes\\TTVITEM.prg 19: Call to function '_parnl' with no prototype in function HB_FUN_TVSETTEXTIMAGE
*** 2 errors in Compile ***
TLIB 4.5 Copyright (c) 1987, 1999 Inprise Corporation

Warning: 'TTVITEM' not found in library
Warning: 'TTVITEM.OBJ' file not found
[/blue]

Pablo Andrés Reyes Rivera
FWH 2.7 - xHarbour Compiler build 0.99.61 (SimpLex) - PellesC
Posts: 782
Joined: Wed Dec 19, 2007 07:50 AM
ImageList en Treeview con Dialogo
Posted: Fri Feb 08, 2008 05:00 PM
Como recomendación, creo que las proximas ediciones de FW deben incluir los BMP de controles radio en BITMAPS\16x16.
Hola Julio:


Un abrazo.
Manuel Mercado
manuelmercado at prodigy dot net dot mx
Posts: 205
Joined: Fri Oct 07, 2005 05:07 PM
ImageList en Treeview con Dialogo
Posted: Fri Feb 08, 2008 05:19 PM

pablo.softgraf

vc, tem que configurar seu bath ou make com que gera a lib para que ela apunte a include de borland.

como esta a gerar a lib?

cumprimentos

Saludos/regards

RenOmaS



skype: americo.balboa
Posts: 7
Joined: Tue Dec 04, 2007 07:59 PM
ImageList en Treeview con Dialogo
Posted: Fri Feb 08, 2008 05:30 PM

Todas as classes estou compilando da mesma maneira ,
se eu compilar a classe TTVITEM sem o pragma begin e pragma end
e sem a adição do metodo SET ela funciona caso contrário da o erro postado anteriormente

eu faço assim pra todas as classes

ECHO Classes - 0151 TTVITEM
ECHO Classes - 0151 TTVITEM -------------------------------------------------------------- >> FIVEHX.LOG
\xharbour\bin\harbour.exe c:\fwh27\source\classes\TTVITEM /n/a/v/w /i\fwh27\include;\xharbour\include >> FIVEHX.LOG
ECHO -O2 -I\xharbour\include -tW TTVITEM.C > b32.bc
c:\borland\bcc55\bin\bcc32.exe -tWM -DHB_GUI -DHB_API_MACROS -DHB_STACK_MACROS -DHB_FM_STATISTICS_OFF -d -a8 -OS -O2 -5 -c @b32.bc >> FIVEHX.LOG
c:\borland\bcc55\bin\tlib.exe FIVEHX -+TTVITEM /0 /P32,, >> FIVEHX.LOG
DEL TTVITEM.C >> FIVEHX.LOG
DEL TTVITEM.OBJ >> FIVEHX.LOG

Posts: 205
Joined: Fri Oct 07, 2005 05:07 PM
ImageList en Treeview con Dialogo
Posted: Fri Feb 08, 2008 06:11 PM
\xharbour\bin\harbour.exe c:\fwh27\source\classes\TTVITEM /n/a/v/w /i\fwh27\include;\xharbour\include;c:\borland\bcc55\include >> FIVEHX.LOG
Saludos/regards

RenOmaS



skype: americo.balboa