StringTree BackGround for VCL Styles

34 views
Skip to first unread message

Erik Virtel

unread,
Aug 8, 2014, 3:24:03 AM8/8/14
to virtual-...@googlegroups.com
Hello,

I've stumbled upon a an issue regarding the use of VCL Styles. 

Without Styles: When it comes to painting the area of a StringTree that lies outside the cells, the Color of the Tree will be used.

With Styles: The Color of the styles scTreeView will be used.

This is done in

function TVTColors.GetBackgroundColor: TColor;
begin
// XE2 VCL Style
{$IF CompilerVersion >= 23 }
 
if FOwner.VclStyleEnabled then
   
Result := StyleServices.GetStyleColor(scTreeView)
 
else
{$IFEND}
   
Result := FOwner.Color;
end;


My point is: The behaviour differs for both versions and I cannot get the same behaviour for a styled StringTree without hacks (see http://stackoverflow.com/questions/25080046/how-can-i-set-the-background-color-for-a-stringtree-with-vcl-styles).

I would prefer to be able to make the StringTree behave the same way for the styled mode but:
- changing scTreeView for the style is not an option since it affects all TreeViews
- simply using the FOwner.Color will change current behaviour, which was obviously intended

How can we use the background also when styles are active?

Joachim Marder

unread,
Aug 10, 2014, 5:18:10 PM8/10/14
to virtual-...@googlegroups.com
Dear Erik

I do not use VCL styles, so there is unfortunately not much I can contribute here. But I wonder: Is the background color more difficiult to change for a single styled tree than other colors? To me it always seemed to be part of the concept that styled controls ignore e.g. their Color property.

Joachim



--
You received this message because you are subscribed to the Google Groups "Virtual Treeview" group.
To unsubscribe from this group and stop receiving emails from it, send an email to virtual-treevi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dmitri

unread,
Aug 16, 2014, 4:20:58 AM8/16/14
to virtual-...@googlegroups.com
I think we could check whether FOwner.Color color first, and use styled one only if it left by default. If programmer changed the color, he is responsible for changing it in themes too.
I'd rewrite the code like below:

 

function TVTColors.GetBackgroundColor: TColor;
begin
// XE2 VCL Style
{$IF CompilerVersion >= 23 }

if (FOwner.VclStyleEnabled) and (FOwner.Color = clWindow) then

Erik Virtel

unread,
Aug 18, 2014, 4:14:21 AM8/18/14
to virtual-...@googlegroups.com
Pondering about it for a while I think the current implementation represents the expected behavior and should remain. It is true that styled controls ignore their color properties by default.

I'll go with the detour workaround from stack overflow (for all VSTs) or using the OnAfterItemPaint and OnPaintBackground events (for specific VSTs).


--
Reply all
Reply to author
Forward
0 new messages