Treeview with checkbox ?

User avatar
Patrick Mast
Posts: 244
Joined: Sat Mar 03, 2007 8:42 pm

Treeview with checkbox ?

Post by Patrick Mast »

Hello,

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

Patrick
User avatar
Maurizio
Posts: 705
Joined: Mon Oct 10, 2005 1:29 pm
Contact:

Post by Maurizio »

You have to modify the resource of the TREEVIEW control (RC or DLL)
checkboxes = Yes

Maurizio
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post 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
User avatar
Patrick Mast
Posts: 244
Joined: Sat Mar 03, 2007 8:42 pm

Post 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
User avatar
jose_murugosa
Posts: 943
Joined: Mon Feb 06, 2006 4:28 pm
Location: Uruguay
Contact:

Post by jose_murugosa »

James,

Could you please send this samples to me too?

jmurugosa@gmail.com

Thanks
Saludos/Regards,
José Murugosa
FWH + Harbour + Bcc7. Una seda!
User avatar
Patrick Mast
Posts: 244
Joined: Sat Mar 03, 2007 8:42 pm

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post 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 )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
ctoas
Posts: 103
Joined: Wed Oct 26, 2005 2:38 pm
Location: São Paulo - Brasil
Contact:

Post 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
Christiano Augusto Silveira
christiano.silveira@gmail.com

MaxxTech Soluções em TI
http://www.maxxtech.com.br
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Christiano,

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

Antonio Linares
www.fivetechsoft.com
User avatar
goosfancito
Posts: 1392
Joined: Fri Oct 07, 2005 7:08 pm

Post 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
Un aporte chico hace grandes cambios.
Apoyemos al proyecto "Hogar pimpinela"
Bajate la aplicación (gratuita) y encuentra en ella toda la info de como podes colaborar.
GRACIAS!
https://play.google.com/store/apps/deta ... .acomprar
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Gustavo,

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

Antonio Linares
www.fivetechsoft.com
User avatar
goosfancito
Posts: 1392
Joined: Fri Oct 07, 2005 7:08 pm

Post 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)

Un aporte chico hace grandes cambios.
Apoyemos al proyecto "Hogar pimpinela"
Bajate la aplicación (gratuita) y encuentra en ella toda la info de como podes colaborar.
GRACIAS!
https://play.google.com/store/apps/deta ... .acomprar
User avatar
goosfancito
Posts: 1392
Joined: Fri Oct 07, 2005 7:08 pm

Re: Treeview with checkbox ?

Post 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
Un aporte chico hace grandes cambios.
Apoyemos al proyecto "Hogar pimpinela"
Bajate la aplicación (gratuita) y encuentra en ella toda la info de como podes colaborar.
GRACIAS!
https://play.google.com/store/apps/deta ... .acomprar
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post 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
regards, saludos

Antonio Linares
www.fivetechsoft.com
Horizon
Posts: 997
Joined: Fri May 23, 2008 1:33 pm

Post 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,
Regards,

Hakan ONEMLI

Harbour & VS 2019 & FWH 20.12
Post Reply