Page 1 of 2

Color of DCTreeItem and DCSubMenu

Posted: Tue Nov 23, 2021 8:49 am
by Wolfgang Ciriack
Hi Roger,

is it possible to set the text color of DCTreeitem and DCSubmenu with OWNERDRAW ?
I can set the background color but not the item color.
Or does the color comes from windows system colors ?

Re: Color of DCTreeItem and DCSubMenu

Posted: Tue Nov 23, 2021 12:02 pm
by rdonnay
Sorry, but XbpTreeview and XbpTreeviewItem do not support owner drawing.

DCSUBMENU does support owner drawing.

Re: Color of DCTreeItem and DCSubMenu

Posted: Tue Nov 23, 2021 9:41 pm
by Wolfgang Ciriack
Hello Roger,
i mean your command DCSUBMENU...OWNERDRAW...
I have initialisied this with

Code: Select all

	DC_XbpMenuConfig({M->oGDL:Color_Background, ;	     //  1 - Sub Menu Background Color
					  GRA_CLR_BLACK, ;		      	     //  2 - Sub Menu Vertical Bar Foreground Color
					  GRA_CLR_HIGHLIGHT, ;		     //  3 - Sub Menu Vertical Bar Background Color
					  GRA_CLR_BLACK, ;			     //  4 - Sub Menu Outline Color
					  '11.Arial Fett', ;			     //  5 - Sub Menu Vertical Bar Font
					  .F., ;
					  '10.Marlett', ;				     //  6 - Sub Menu Check Character Font
					  'b', ;					     //  7 - Sub Menu Check Character
					  M->oGDL:Color_Foreground, ;	     //  8 - Menu Bar Foreground Color
					  M->oGDL:Color_Background, ;	     //  9 - Menu Bar Background Color
					  GRA_CLR_BLACK, ;			    // 10 - Sub Menu Foreground Color
					  '8.Arial'})				    // 11 - Menu Bar Font
But the Submenu Foreground Color does not change when i try to set it to GRA_CLR_WHITE (on GRA_CLR_BLACK), so i have black on black :( .
The DCMENUBAR does it in white on black.

Re: Color of DCTreeItem and DCSubMenu

Posted: Wed Dec 01, 2021 12:25 pm
by rdonnay
The problem appears to be that the foreground color never changes from BLACK.
I am working on this.

I was just getting ready to release build 268, and now this.

Re: Color of DCTreeItem and DCSubMenu

Posted: Wed Dec 01, 2021 2:53 pm
by rdonnay
I have a fix for you.

In the file _DCCLASS.PRG, look for the following line of code (approx. line 5803) :

Code: Select all

        aDAttrs[GRA_AS_COLOR] := GraMakeRGBColor(IIF(lEnabled,{0,0,0},{180,180,180}))
Replace it with the following:

Code: Select all

        nColor := ::fgColor 
        IF Valtype(nColor) == 'A'
          nColor := GraMakeRGBColor(nColor)
        ENDIF
        aDAttrs[GRA_AS_COLOR] := nColor
        nColor := ::bgColor
        IF Valtype(nColor) == 'A'
          nColor := GraMakeRGBColor(nColor)
        ENDIF
        aDAttrs[GRA_AS_BACKCOLOR] := ::nColor
Rebuild dclipx.dll by running build20.bat

This fix will be in build 268.

Re: Color of DCTreeItem and DCSubMenu

Posted: Thu Dec 02, 2021 12:15 pm
by Wolfgang Ciriack
Hello Roger,
thanks for this solution, works perfect for DCSUBMENU.
Is this possible to change this for DCTreeitem, too (is also Black on Black) ?

Re: Color of DCTreeItem and DCSubMenu

Posted: Thu Dec 02, 2021 4:04 pm
by rdonnay
I still don't understand about DCTREEITEM.

Can you give me a sample program?

Re: Color of DCTreeItem and DCSubMenu

Posted: Sun Dec 05, 2021 12:52 am
by Wolfgang Ciriack
Hello Roger,
its simple, try to make a Treeview with white text on black background.

Re: Color of DCTreeItem and DCSubMenu

Posted: Sun Dec 05, 2021 4:04 am
by Auge_Ohr
hi Wolfgang,
Wolfgang Ciriack wrote: Sun Dec 05, 2021 12:52 am its simple, try to make a Treeview with white text on black background.
you can try this

Code: Select all

#define TV_FIRST          	0x1100
#define TVM_SETBKCOLOR          (TV_FIRST + 29)
#define TVM_SETTEXTCOLOR        (TV_FIRST + 30)

INLINE METHOD APISetBkColor(clrBk)
LOCAL hRet  := 0
   hRet := @USER32:SendMessageA(hTreeView,TVM_SETBKCOLOR, 0, clrBk )
RETURN hRet

INLINE METHOD APISetTextColor(clrText)
LOCAL hRet  := 0
   hRet := @USER32:SendMessageA(hTreeView,TVM_SETTEXTCOLOR, 0, clrText )
RETURN hRet
https://docs.microsoft.com/de-de/window ... setbkcolor
https://docs.microsoft.com/de-de/window ... ttextcolor

remember to switch OFF "visual Style"

Re: Color of DCTreeItem and DCSubMenu

Posted: Sun Dec 05, 2021 6:48 am
by rdonnay
It appears that this is a bug in XbpTreeView.

The :setColorFG() method will not allow any foreground color other than black.
I am surprised that nobody has reported this before now.