To change color of a tree object

To change color of a tree object

Postby MarcoBoschi » Fri Sep 22, 2006 7:14 am

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
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Postby Antonio Linares » Fri Sep 22, 2006 8:14 am

Marco,

Please review samples\TreeDlg.prg
regards, saludos

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

Postby MarcoBoschi » Fri Sep 22, 2006 8:31 am

Yes but background color of items remains White!

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

Postby Antonio Linares » Fri Sep 22, 2006 8:46 am

Marco,

Please check that you have these lines in Class TTreeView:
Code: Select all  Expand view
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
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby MarcoBoschi » Fri Sep 22, 2006 9:12 am

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
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Postby Enrico Maria Giordano » Sun Sep 24, 2006 7:09 am

Antonio, do you need a sample of this problem?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Antonio Linares » Sun Sep 24, 2006 8:50 am

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

Postby Enrico Maria Giordano » Sun Sep 24, 2006 10:26 am

Here it is:

Code: Select all  Expand view
#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
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby MarcoBoschi » Sun Sep 24, 2006 1:57 pm

Thank to Yout Enrico and Antonio.
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Postby Antonio Linares » Sun Sep 24, 2006 2:01 pm

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

Postby MarcoBoschi » Sun Sep 24, 2006 2:07 pm

Thank you very much
Muchas gracias
Grazie

Marco :)
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Postby Antonio Linares » Sun Sep 24, 2006 2:22 pm

regards, saludos

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

Postby Antonio Linares » Sun Sep 24, 2006 2:28 pm

regards, saludos

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

Postby Enrico Maria Giordano » Sun Sep 24, 2006 3:01 pm

Solved! :-)

Code: Select all  Expand view
#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
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby MarcoBoschi » Sun Sep 24, 2006 5:14 pm

Very good!
After dinner I'll try it!
Thanks again
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Next

Return to FiveWin for Harbour/xHarbour

Who is online

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