Negrita en in ITEM del tree?

Negrita en in ITEM del tree?

Postby goosfancito » Tue Aug 24, 2021 9:20 am

Hola.
Quiero que al hacer un click se ponga en negrita ese ITEM del tree,
como tengo que ponerlo en negrita a ese item?
Code: Select all  Expand view

METHOD MenuPop( nRow, nCol )
   LOCAL oMenu
   LOCAL oItem := ::oTree:hitTest( nRow, nCol )
...
 
FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
User avatar
goosfancito
 
Posts: 1954
Joined: Fri Oct 07, 2005 7:08 pm

Re: Negrita en in ITEM del tree?

Postby Antonio Linares » Tue Aug 24, 2021 11:17 am

hay que usar estos flags:

Code: Select all  Expand view
    TV_ITEM tvi;
    tvi.mask = TVIF_STATE | TVIF_HANDLE;
    tvi.hItem = hItem;
    tvi.state = TVIS_BOLD;
    tvi.stateMask = TVIS_BOLD;
    SetItem(&tvi);


ahora hay que ver como asignarlos a un item ya existente:

SetItemState( hItem, TVIS_BOLD, TVIS_BOLD );
and we may need to reset the string of the item after the bold state was set to the item
https://www.codeproject.com/Questions/444245/Changing-to-state-of-tree-item-to-BOLD-does-not-ch
regards, saludos

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

Re: Negrita en in ITEM del tree?

Postby goosfancito » Tue Aug 24, 2021 9:31 pm

Nunca trabaje con los flags, no se siquiera como insertarlos en mi source.
FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
User avatar
goosfancito
 
Posts: 1954
Joined: Fri Oct 07, 2005 7:08 pm

Re: Negrita en in ITEM del tree?

Postby hmpaquito » Wed Aug 25, 2021 7:42 am

Hace un monton de años coloree el tree modificando los fuentes y a base de pasar parametros a TreeDraw.c y tambien modificando el TreeView.prg-> DrawItem()

No tengo lo de poner en negrita al pulsar un item. Eso requeriria dinamismo en los colores: Refrescar el tree cada vez que se pulse un item... o eso creo...
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: Negrita en in ITEM del tree?

Postby Antonio Linares » Wed Aug 25, 2021 11:49 am

Una primera versión:

Code: Select all  Expand view
HB_FUNC( TVSETITEMBOLD ) // ( hWnd, hTreeItem, lBold ) --> lSuccess
{
   UINT uiMask;

   #ifndef _WIN64
      hb_retl( TreeView_GetItemState( ( HWND ) hb_parnl( 1 ), ( HTREEITEM ) hb_parnl( 2 ), &uiMask ) );
   #else
      hb_retl( TreeView_GetItemState( ( HWND ) hb_parnll( 1 ), ( HTREEITEM ) hb_parnll( 2 ), &uiMask ) );
   #endif

   #ifndef _WIN64
      TreeView_SetItemState( ( HWND ) hb_parnl( 1 ), ( HTREEITEM ) hb_parnl( 2 ), &uiMask, hb_parl( 3 ) ? TVIS_BOLD: 0 );
   #else
      TreeView_SetItemState( ( HWND ) hb_parnll( 1 ), ( HTREEITEM ) hb_parnll( 2 ), &uiMask, hb_parl( 3 ) ? TVIS_BOLD: 0 );
   #endif
}
regards, saludos

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

Re: Negrita en in ITEM del tree?

Postby goosfancito » Wed Aug 25, 2021 2:11 pm

por lo que veo, en el mismo source que uso el fwh puedo insertar codigo c.
es asi?
FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
User avatar
goosfancito
 
Posts: 1954
Joined: Fri Oct 07, 2005 7:08 pm

Re: Negrita en in ITEM del tree?

Postby Antonio Linares » Wed Aug 25, 2021 3:44 pm

Si

En la Clase TTVItem tienes que añadir este nuevo método:

METHOD Bold( lOnOff ) INLINE TVSetItemBold( ::oTree:hWnd, ::hItem, lOnOff )

y al final de tu PRG esribe:
Code: Select all  Expand view
#pragma BEGINDUMP

#define _WIN32_IE 0x0500
#include <Windows.h>
#include <CommCtrl.h>
#include <hbapi.h>

HB_FUNC( TVSETITEMBOLD ) // ( hWnd, hTreeItem, lBold ) --> lSuccess
{
   UINT uiMask1, uiMask2 = 0;

   #ifndef _WIN64
      hb_retl( TreeView_GetItemState( ( HWND ) hb_parnl( 1 ), ( HTREEITEM ) hb_parnl( 2 ), &uiMask1 ) );
   #else
      hb_retl( TreeView_GetItemState( ( HWND ) hb_parnll( 1 ), ( HTREEITEM ) hb_parnll( 2 ), &uiMask1 ) );
   #endif

   if( hb_parl( 3 ) )
      uiMask2 = TVIS_BOLD;

   #ifndef _WIN64
      TreeView_SetItemState( ( HWND ) hb_parnl( 1 ), ( HTREEITEM ) hb_parnl( 2 ), uiMask1, uiMask2 );
   #else
      TreeView_SetItemState( ( HWND ) hb_parnll( 1 ), ( HTREEITEM ) hb_parnll( 2 ), uiMask1, uiMask2 );
   #endif
}

#pragma ENDDUMP
regards, saludos

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

Re: Negrita en in ITEM del tree?

Postby goosfancito » Wed Aug 25, 2021 8:01 pm

Luego de hacer las modificaciones que me indicas, puse asi y no me funcionó. Que estoy no entendiendo?


Code: Select all  Expand view
CASE nOpcion == VK_INSERT     // cortar
      ::nHitemCortar := oItem:hitem
      oItem:bold(.t.)
 
FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
User avatar
goosfancito
 
Posts: 1954
Joined: Fri Oct 07, 2005 7:08 pm

Re: Negrita en in ITEM del tree?

Postby Antonio Linares » Thu Aug 26, 2021 9:16 am

Esta versión funciona bien aqui, muestra negrita, lo que falta es poder quitar negrita

Code: Select all  Expand view
HB_FUNC( TVSETITEMBOLD ) // ( hWnd, hTreeItem, lBold ) --> lSuccess
{
   UINT uiMask1, uiMask2 = 0, bBold = hb_parl( 3 );

   #ifndef _WIN64
      hb_retl( TreeView_GetItemState( ( HWND ) hb_parnl( 1 ), ( HTREEITEM ) hb_parnl( 2 ), &uiMask1 ) );
   #else
      hb_retl( TreeView_GetItemState( ( HWND ) hb_parnll( 1 ), ( HTREEITEM ) hb_parnll( 2 ), &uiMask1 ) );
   #endif

   if( bBold )
      uiMask2 = TVIS_BOLD;
   else
      uiMask1 = uiMask1 ^ TVIS_BOLD;  

   #ifndef _WIN64
      TreeView_SetItemState( ( HWND ) hb_parnl( 1 ), ( HTREEITEM ) hb_parnl( 2 ), uiMask1, uiMask2 );
   #else
      TreeView_SetItemState( ( HWND ) hb_parnll( 1 ), ( HTREEITEM ) hb_parnll( 2 ), uiMask1, uiMask2 );
   #endif

   hb_retl( uiMask1 & TVIS_BOLD );
}
regards, saludos

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

Re: Negrita en in ITEM del tree?

Postby goosfancito » Thu Aug 26, 2021 12:46 pm

bien, lo dejo no hay drama. sigo no es importante que lo tenga en negrita.
aca no me funciona.
gracias
FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
User avatar
goosfancito
 
Posts: 1954
Joined: Fri Oct 07, 2005 7:08 pm

Re: Negrita en in ITEM del tree?

Postby Antonio Linares » Thu Aug 26, 2021 3:47 pm

El ejemplo FWH\samples\pim.prg probando el nuevo método Bold() en Class TVItem:

El item que se ha puesto en negrita es "country"

Image
regards, saludos

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

Re: Negrita en in ITEM del tree?

Postby goosfancito » Thu Aug 26, 2021 6:59 pm

Antonio
O sea que cuando lo estas creando lo pones en negrita?
porque yo intente poner en negrita uno que ya tenia creado.
FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
User avatar
goosfancito
 
Posts: 1954
Joined: Fri Oct 07, 2005 7:08 pm

Re: Negrita en in ITEM del tree?

Postby Antonio Linares » Fri Aug 27, 2021 5:55 am

Los items ya estan creados, lo que se hace es cambiarlos a negrita o normal
regards, saludos

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

Re: Negrita en in ITEM del tree?

Postby goosfancito » Wed Apr 27, 2022 11:08 am

Antonio,

La idea de este codigo es que cuando agrego una rama "padre" me lo ponga en negrita, intento hacer esto pero me tira error

Code: Select all  Expand view
        oSubItem := oItem:ADD( oQry:FieldGet( "c7" ) + "     " + ::cCargo )

         IF ( oSubItem:GetSelected() != NIL )
            oSubItem:GetSelected():Bold()
         ENDIF
 


Error description: Error BASE/1004 Message not found: TTVITEM:GETSELECTED
Args:
[ 1] = O TTVITEM

Stack Calls
===========
Called from: => __ERRRT_SBASE( 0 )
Called from: ../../../tobject.prg => TTVITEM:ERROR( 148 )
FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
User avatar
goosfancito
 
Posts: 1954
Joined: Fri Oct 07, 2005 7:08 pm

Re: Negrita en in ITEM del tree?

Postby Antonio Linares » Wed Apr 27, 2022 11:56 am

El mensaje GetSelected tiene que enviarse al árbol, no a un item

oTree:GetSelected()
regards, saludos

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

Next

Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 80 guests