Page 1 of 3

Treeview with checkbox ?

Posted: Fri May 18, 2007 4:27 pm
by Patrick Mast
Hello,

How can we make a treeview with checkboxes in FWH so it looks something like this:
Image

Patrick

Posted: Fri May 18, 2007 4:58 pm
by Maurizio
You have to modify the resource of the TREEVIEW control (RC or DLL)
checkboxes = Yes

Maurizio

Posted: Fri May 18, 2007 10:47 pm
by James Bott
Patrick,

If you will send me your email address, I will send you some sample code that I got from somewhere. I haven't tried it myself.

It is several files in a zip file or I would just post it here.

James

Posted: Sat May 19, 2007 8:08 am
by Patrick Mast
James Bott wrote:If you will send me your email address, I will send you some sample code that I got from somewhere. I haven't tried it myself.
It is several files in a zip file or I would just post it here.
It's "patrick . mast @ winfakt . com"

Thank you James.

Patrick

Posted: Sat May 19, 2007 1:36 pm
by jose_murugosa
James,

Could you please send this samples to me too?

jmurugosa@gmail.com

Thanks

Posted: Sat May 19, 2007 7:26 pm
by Patrick Mast
James Bott wrote:If you will send me your email address, I will send you some sample code that I got from somewhere. I haven't tried it myself.
It is several files in a zip file or I would just post it here.
Got the files. Thank you. But.. This is exactly how we did it for the printscreen I posted in this 1st message. But this is not NATIVE. It's tricking the class :)
I was hoping we could do it natively with the standard FWH Tree class.

Antonio?

Patrick

Posted: Sat May 19, 2007 10:43 pm
by Antonio Linares
In the resources, this treeview style has to be used:
#define TVS_CHECKBOXES 0x0100

Code: Select all

#include <windows.h>
#include <commctrl.h>
#include <hbapi.h>

HB_FUNC( TVSETCHECK )
{
   HWND hWnd = ( HWND ) hb_parnl( 1 );
   HTREEITEM hItem = ( HTREEITEM ) hb_parnl( 2 );

   TreeView_SetItemState( hWnd, hItem, hb_parl( 3 ) );
}
 
HB_FUNC( TVGETCHECK )
{
   HWND hWnd = ( HWND ) hb_parnl( 1 );
   HTREEITEM hItem = ( HTREEITEM ) hb_parnl( 2 );

   hb_retl( TreeView_GetCheckState( hWnd, hItem ) );
}

Code: Select all

   METHOD GetCheck( oItem ) INLINE ; 
      If( oItem == nil, oItem := ::GetSelected(), nil ), ; 
      TVGetCheck( ::hWnd, oItem:hWnd )

   METHOD SetCheck( oItem, lOnOff ) INLINE ; 
      If( oItem == nil, oItem := ::GetSelected(), nil ), ; 
      TVSetCheck( ::hWnd, oItem:hWnd, lOnOff )

Posted: Mon Jun 02, 2008 9:05 pm
by ctoas
Antonio, this is a solution that I already tried there is some time.
I just don t know only where you put the codes identified

Posted: Mon Jun 02, 2008 9:27 pm
by Antonio Linares
Christiano,

You have to include it in the Class TTreeView at source/classes/treeview.prg

Posted: Thu Oct 09, 2008 2:49 pm
by goosfancito
Antonio,

A ver si me explico el problema que tengo (o quizas no sea problema y tenga que hacerlo por lineas de programas)
Tengo un Tree con 3 ramas y cada rama con items, cada item tiene un checkbox, cuando selecciono en el item de la rama los item de esa rama no se seleccionan. porque?

Gracias.
Antonio Linares wrote:Christiano,

You have to include it in the Class TTreeView at source/classes/treeview.prg

Posted: Thu Oct 09, 2008 6:32 pm
by Antonio Linares
Gustavo,

Por favor proporciona un pequeño ejemplo PRG autocontenido para probarlo aqui, gracias

Posted: Thu Oct 09, 2008 11:03 pm
by goosfancito
Antonio Linares wrote:Gustavo,

Por favor proporciona un pequeño ejemplo PRG autocontenido para probarlo aqui, gracias

Code: Select all

METHOD pantalla() CLASS TABMUSUARIOS
   LOCAL oDlg,;
         oTree,;
         oFolder,;
         oDatos  := Array(3),;
         vDatos  := Array(3),;
         oTextos := Array(4),;
         oBtns   := Array(2)

   ::oQuery:= ::oConexion:query(::cQuery)

   DEFINE DIALOG oDlg resource "DLG_USUARIOS"

      //----------( Botones principales )----------

      REDEFINE BUTTON oBtns[1] ID 204 OF oDlg
      REDEFINE BUTTON oBtns[2] ID 205 OF oDlg

      //----------( Folder )----------

      REDEFINE FOLDER oFolder ID 4002 OF oDlg ;
         PROMPT "Datos", "Permisos", "Llave";
         DIALOGS "DLG_TAB1", "DLG_TAB2", "DLG_TAB3"

      oFolder:aEnable := {.T., .T., .T.}

      //----------( Tree )----------

      oTree:= TTreeView():REDEFINE(206, oFolder:aDialogs[2])

      //----------( Acción botones )----------

      oBtns[2]:bAction:={|| oDlg:END() }

   ACTIVATE DIALOG oDlg CENTERED ON INIT (definirTree(oTree))

   msgstop( oTree:IsChecked( 1 ) )

   RETURN (NIL)

//------------------------------------------------------------------------------

FUNCTION definirTree(oTree)

   LOCAL oMenu    := array(3), ;
         oSubMenu := array(10)

   oMenu[1]:= oTree:ADD("Principal")
      oSubMenu[1]:= oMenu[1]:ADD("Imprimir...")

   oMenu[2]:= oTree:ADD("Proyectos")
      oSubMenu[6]:= oMenu[2]:ADD("Definir Proyectos")
      oSubmenu[7]:= oMenu[2]:ADD("Actualización datos")

   oTree:expand()

   RETURN (NIL)


Re: Treeview with checkbox ?

Posted: Wed Oct 15, 2008 3:22 am
by goosfancito
Patrick,

Can you send me your example dialog + tree + checkbox.

Tank´s
Patrick Mast wrote:Hello,

How can we make a treeview with checkboxes in FWH so it looks something like this:
Image

Patrick

Posted: Wed Oct 15, 2008 7:31 am
by Antonio Linares
Gustavo,

test.prg

Code: Select all

#include "FiveWin.ch"

function Main()

   local oDlg, oTree 

   DEFINE DIALOG oDlg

   @ 0, 0 TREEVIEW oTree OF oDlg SIZE 200, 200 CHECKBOXES

   ACTIVATE DIALOG oDlg CENTERED ON INIT definirTree( oTree ) 

   MsgInfo( oTree:GetCheck( oTree:aItems[ 1 ] ) ) 

return nil 

function definirTree(oTree) 

   local oMenu    := array(3), ; 
         oSubMenu := array(10) 

   oMenu[1]:= oTree:Add( "Principal" ) 
      oSubMenu[1]:= oMenu[1]:Add( "Imprimir..." ) 

   oMenu[2]:= oTree:Add( "Proyectos" ) 
      oSubMenu[6]:= oMenu[2]:Add( "Definir Proyectos" ) 
      oSubmenu[7]:= oMenu[2]:Add( "Actualización datos" ) 

   oTree:expand() 

return nil 
Image

Posted: Wed Oct 15, 2008 7:55 am
by Horizon
Hi Antonio,

Should it be changed any class to run this example. I have compiled it and there is not any checkbox.

Thanks,