TreeView desde codigo

TreeView desde codigo

Postby jllinas » Sun Jun 11, 2006 3:17 am

Hola,

¿Es que la clase TreeView se puede utilizar desde codigo en un dialogo? En SAMPLES\TREEVIEW.PRG solo aparece desde recursos, y cuando lo incluyo desde codigo me da el clásico error "Cannot Create Dialog..."

¿Alguien tiene un ejemplo que comparta conmigo?

Gracias anticipadas,
Julio Llinás
Visita mi Blog en http://mangucybernetico.blogspot.com/
xHarbour 1.1.0 + FWH810 + Borland 5.5.1
User avatar
jllinas
 
Posts: 189
Joined: Fri Oct 14, 2005 12:33 am
Location: Santo Domingo, Dominican Republic

Postby Antonio Linares » Mon Jun 12, 2006 9:27 am

Julio,

Tienes que añadir este método a la clase TTreeView en source\classes\ttreevie.prg:
Code: Select all  Expand view
   METHOD cToChar() INLINE Super:cToChar( CTRL_NAME )

Y si añades este comando a FiveWin.ch:
Code: Select all  Expand view
#xcommand @ <nRow>, <nCol> TREEVIEW [<oTV>] ;                                           
             [ SIZE <nWidth>, <nHeight> ] ;
             [ <of: OF, WINDOW, DIALOG> <oWnd> ] ;
             [ <design: DESIGN> ] ;
             [ <pixel: PIXEL> ] ;
             [ COLOR <nClrFore> [,<nClrBack>] ] ;
             [ MESSAGE <cMsg> ] ;
       => ;
          [ <oTV> := ] TTreeView():New( <nRow>, <nCol>, <oWnd>, <nClrFore>, <nClrBack>,;
                                        [<.pixel.>], [<.design.>], <nWidth>, <nHeight>,;
                                        [<cMsg>] )

Entonces puedes probar este ejemplo:
Code: Select all  Expand view
#include "FiveWin.ch"
#include "WColors.ch"

function Main()

   local oDlg, oTree
   
   DEFINE DIALOG oDlg TITLE "TreeView from source"
   
   @ 0.5, 1 TREEVIEW oTree OF oDlg SIZE 80, 60 COLOR 0, GetSysColor( COLOR_WINDOW )
   
   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT AddItems( oTree )
   
return nil   

function AddItems( oTree )

   local oItem1, oItem2, oItem3
   
   oItem1 = oTree:Add( "First" )
   oItem1:Add( "One" )
   oItem1:Add( "Two" )
   oItem1:Add( "Three" )
   oItem2 = oTree:Add( "Second" )   
   oItem2:Add( "Hello" )
   oItem2:Add( "World" )
   oItem3 = oTree:Add( "Third" )
   oItem3:Add( "Last" )
   oItem3:Add( "item" )
   
return nil         

Que se ve así:
Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41937
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby jllinas » Tue Jun 13, 2006 9:00 pm

Gracias Antonio,

Funcionó de maravillas. Solo cambié COLOR_WINDOW por 15, y me funcionó bien.

Gracias de nuevo...
Julio Llinás
Visita mi Blog en http://mangucybernetico.blogspot.com/
xHarbour 1.1.0 + FWH810 + Borland 5.5.1
User avatar
jllinas
 
Posts: 189
Joined: Fri Oct 14, 2005 12:33 am
Location: Santo Domingo, Dominican Republic


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 110 guests