Tree with check

Tree with check

Postby Maurizio » Mon Oct 02, 2006 3:53 pm

I have a Tree with TVS_CHECKBOXES.
Is it possible to know if CHECKBOX is ON or OFF ( without use :Cargo ) ?

Regards Maurizio
User avatar
Maurizio
 
Posts: 825
Joined: Mon Oct 10, 2005 1:29 pm

Postby Antonio Linares » Tue Oct 03, 2006 5:29 am

Maurizio,
Code: Select all  Expand view  RUN
HB_FUNC( TVISCHECKED )  // hTreeView, hItem
{
   hb_retl( TreeView_GetCheckState( ( HWND ) hb_parnl( 1 ), ( HTREEITEM ) hb_parnl( 2 ) ) );
}


MsgInfo( TVIsChecked( oTree:hWnd, oTVItem:hItem ) )
regards, saludos

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

Postby Maurizio » Tue Oct 03, 2006 6:36 am

It works.

Thanks again, Antonio
User avatar
Maurizio
 
Posts: 825
Joined: Mon Oct 10, 2005 1:29 pm

Postby Maurizio » Tue Oct 03, 2006 6:57 am

Hello Antonio

is possible enable or disable CHECKBOX ?

Regards Maurizio
User avatar
Maurizio
 
Posts: 825
Joined: Mon Oct 10, 2005 1:29 pm

Postby Antonio Linares » Tue Oct 03, 2006 8:05 am

Maurizio,
Code: Select all  Expand view  RUN
HB_FUNC( TVSETCHECK )  // hTreeView, hItem, lOnOff
{
   hb_retl( TreeView_SetCheckState( ( HWND ) hb_parnl( 1 ), ( HTREEITEM ) hb_parnl( 2 ), hb_parl( 3 ) ) );
}
regards, saludos

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

Postby Maurizio » Tue Oct 03, 2006 8:50 am

Hello Antonio

I have this error

Expression syntax in function HB_FUN_TVSETCHECK.

But the function TreeView_SetCheckState , chek or unchek the CHEKBOX, that I need is to disable or hide the chekbox in front of the Item .

Regrads Maurizio
User avatar
Maurizio
 
Posts: 825
Joined: Mon Oct 10, 2005 1:29 pm

Postby Antonio Linares » Tue Oct 03, 2006 9:54 am

Maurizio,

I don't know if it is possible to hide it.
regards, saludos

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

Postby Rossine » Tue Oct 03, 2006 8:59 pm

Olá Maurizio,

Tente Isto: Mude em \fwh\source\classes\TTREEVIE.PRG

Code: Select all  Expand view  RUN
...
   METHOD SetCheck( nIt, lFlag ) INLINE TVSetCheck( ::hWnd, nIt, lFlag )

   METHOD IsChecked( nIt ) INLINE TVIsChecked( ::hWnd, nIt )
...


e isto

Code: Select all  Expand view  RUN
#pragma BEGINDUMP

#include "windows.h"
#include "commctrl.h"
#include "hbapi.h"

HB_FUNC( TVSETCHECK ) // hTreeView, hItem, lOnOff
{
TVITEM tvItem;
   HWND hWnd = ( HWND ) hb_parnl( 1 );
   HTREEITEM hItem = ( HTREEITEM ) hb_parnl( 2 );

tvItem.mask = TVIF_HANDLE | TVIF_STATE;
tvItem.hItem = hItem;
tvItem.stateMask = TVIS_STATEIMAGEMASK;

/*
Since state images are one-based, 1 in this macro turns the check off,
and
2 turns it on.
*/
tvItem.state = INDEXTOSTATEIMAGEMASK(( hb_parl( 3 ) ? 2 : 1));

   hb_retl( ( BOOL ) TreeView_SetItem( ( HWND ) hb_parnl( 1 ), &tvItem ) );
}

HB_FUNC( TVISCHECKED ) // hTreeView, hItem
{
TVITEM tvItem;
   HWND hWnd = ( HWND ) hb_parnl( 1 );
   HTREEITEM hItem = ( HTREEITEM ) hb_parnl( 2 );

// Prepare to receive the desired information.
tvItem.mask = TVIF_HANDLE | TVIF_STATE;
tvItem.hItem = hItem;
tvItem.stateMask = TVIS_STATEIMAGEMASK;

// Request the information.
   hb_retl( ( BOOL ) TreeView_GetItem( ( HWND ) hb_parnl( 1 ), &tvItem ) );

// Return zero if it's not checked, or nonzero otherwise.
   hb_retl( (BOOL) (tvItem.state >> 12) -1 ) ;
}

#pragma ENDDUMP



Use assim:
Code: Select all  Expand view  RUN
Para Setar o status:

oTree:SetCheck( oItem:hItem, .F. ) && Uncheck

ou

oTree:SetCheck( oItem:hItem, .T. ) && check

Para Ler o status:

msgstop( oTree:IsChecked( oItem:hItem ) )


Abraços,

Rossine.
Rossine
 
Posts: 344
Joined: Tue Oct 11, 2005 11:33 am


Return to FiveWin for Harbour/xHarbour

Who is online

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