To change color of a tree object

User avatar
MarcoBoschi
Posts: 925
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy
Contact:

To change color of a tree object

Post by MarcoBoschi »

If I try to color a Tree the background of items remain always white.
I have to obtain a tree of the same color of all others objects in a dialog.
Any trick?
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Marco,

Please review samples\TreeDlg.prg
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
MarcoBoschi
Posts: 925
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy
Contact:

Post by MarcoBoschi »

Yes but background color of items remains White!

Saludos
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Marco,

Please check that you have these lines in Class TTreeView:

Code: Select all

METHOD ReDefine( nId, oWnd, nClrFore, nClrBack, lDesign, cMsg ) CLASS TTreeView

   DEFAULT oWnd     := GetWndDefault(),;
           nClrFore := oWnd:nClrText,;
           nClrBack := oWnd:nClrPane,; // GetSysColor( COLOR_WINDOW ),;
           lDesign  := .f.
...
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
MarcoBoschi
Posts: 925
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy
Contact:

Post by MarcoBoschi »

Antonio,
The answer is Yes.
=============== from ttreevie.prg ==============
METHOD ReDefine( nId, oWnd, nClrFore, nClrBack, lDesign, cMsg ) CLASS TTreeView

DEFAULT oWnd := GetWndDefault(),;
nClrFore := oWnd:nClrText,;
nClrBack := oWnd:nClrPane,; // GetSysColor( COLOR_WINDOW ),;
lDesign := .f.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Enrico,

samples\TreeDlg.prg is working fine.

I appreciate if you could provide another sample, thanks :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Here it is:

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg, oTree

    DEFINE DIALOG oDlg;
           SIZE 400, 400

    @ 0, 0 TREEVIEW oTree COLOR CLR_GREEN, CLR_RED

    ACTIVATE DIALOG oDlg;
             ON INIT FILLTREE( oTree );
             CENTER

    RETURN NIL


STATIC FUNCTION FILLTREE( oTree )

    LOCAL oItem

    oItem = oTree:Add( "Test" )

    oItem:Add( "Test1" )
    oItem:Add( "Test2" )
    oItem:Add( "Test3" )

    oTree:Expand()

    RETURN NIL
As you can see, the colors of the subitems are still black on white.

EMG
User avatar
MarcoBoschi
Posts: 925
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy
Contact:

Post by MarcoBoschi »

Thank to Yout Enrico and Antonio.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Enrico, Marco,

If you try to build a similar sample using Word VBA built in Macro Editor, it does not show the BackColor property. It looks as it is not supported by Windows API. We are doing more research.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
MarcoBoschi
Posts: 925
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy
Contact:

Post by MarcoBoschi »

Thank you very much
Muchas gracias
Grazie

Marco :)
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

regards, saludos

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

Post by Antonio Linares »

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Solved! :-)

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg, oTree

    DEFINE DIALOG oDlg;
           SIZE 400, 400

    @ 0, 0 TREEVIEW oTree COLOR CLR_GREEN, CLR_RED

    ACTIVATE DIALOG oDlg;
             ON INIT FILLTREE( oTree );
             CENTER

    RETURN NIL


STATIC FUNCTION FILLTREE( oTree )

    LOCAL oItem

    oItem = oTree:Add( "Test" )

    oItem:Add( "Test1" )
    oItem:Add( "Test2" )
    oItem:Add( "Test3" )

    oTree:Expand()

    TVSETTEXTCOLOR( oTree:hWnd, CLR_GREEN )
    TVSETBKCOLOR( oTree:hWnd, CLR_RED )

    RETURN NIL


#pragma BEGINDUMP

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

HB_FUNC( TVSETTEXTCOLOR )
{
    hb_retnl( ( LONG ) TreeView_SetTextColor( ( HWND ) hb_parnl( 1 ), hb_parnl( 2 ) ) );
}


HB_FUNC( TVSETBKCOLOR )
{
    hb_retnl( ( LONG ) TreeView_SetBkColor( ( HWND ) hb_parnl( 1 ), hb_parnl( 2 ) ) );
}

#pragma ENDDUMP
EMG
User avatar
MarcoBoschi
Posts: 925
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy
Contact:

Post by MarcoBoschi »

Very good!
After dinner I'll try it!
Thanks again
Post Reply