How to change highlight colour of wxTreeCtrl? Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
User avatar
IronFace
In need of some credit
In need of some credit
Posts: 5
Joined: Mon Dec 25, 2017 5:10 am

How to change highlight colour of wxTreeCtrl?

Post by IronFace »

Hi, guys.

I work at win7 pro with wxWidegets3.03.
I have a problem with wxTreeCtrl. The colour of select highlight is unconspicuous.And when the ctrl lost focus, the item turn gray.

viewtopic.php?f=27&t=7616&p=34711&hilit ... ect#p34711
I find this topic, it said that is a basic windows behaviour.

In wxTreeCtrl, I can't find any Draw/Paint/Render method to override.
So,How to change this appearance?
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: How to change highlight colour of wxTreeCtrl?

Post by ONEEYEMAN »

Hi,
wxWidgets is known for keeping a native behaviour.
What it means is that the library is using "native" set of controls/widgets wherever and whenever possible.

You can try to use conditional compilation in your project by overriding DefWindowProc or any other Windows-specific functions, but don't expect this to be included in the main line of the library.
wx will handle different themes/different resolutions/different OSes for you but, again, it will use native controls, i.e. whatever available from the OS.

If you need such a tweaking - check other Windows-specific library.

Thank you.
User avatar
eranon
Can't get richer than this
Can't get richer than this
Posts: 867
Joined: Sun May 13, 2012 11:42 pm
Location: France
Contact:

Re: How to change highlight colour of wxTreeCtrl?

Post by eranon »

Hello,

Never used the tree control until now, but did this for some wxListCtrl's. Maybe it can drive you to a working direction. Here the wxListCtrl is called lstSessions and it belongs to a panel called ImporterPanel.

Code: Select all

In ctor:
lstSessions->Connect(wxEVT_KILL_FOCUS, wxFocusEventHandler(ImporterPanel::OnListLostFocus), NULL);

void ImporterPanel::OnListLostFocus(wxFocusEvent& event)
{
    // Inhibite change of selected item color when a list loses focus
    event.Skip(false);
}
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]
User avatar
IronFace
In need of some credit
In need of some credit
Posts: 5
Joined: Mon Dec 25, 2017 5:10 am

Re: How to change highlight colour of wxTreeCtrl?

Post by IronFace »

ONEEYEMAN wrote:Hi,
wxWidgets is known for keeping a native behaviour.
What it means is that the library is using "native" set of controls/widgets wherever and whenever possible.

You can try to use conditional compilation in your project by overriding DefWindowProc or any other Windows-specific functions, but don't expect this to be included in the main line of the library.
wx will handle different themes/different resolutions/different OSes for you but, again, it will use native controls, i.e. whatever available from the OS.

If you need such a tweaking - check other Windows-specific library.

Thank you.
Hi, ONEEYEMAN.
I will try this way. This effect not only the wxTreeCtrl. If change this can deal with then all, it should be good.
Thank you.
User avatar
IronFace
In need of some credit
In need of some credit
Posts: 5
Joined: Mon Dec 25, 2017 5:10 am

Re: How to change highlight colour of wxTreeCtrl?

Post by IronFace »

eranon wrote:Hello,

Never used the tree control until now, but did this for some wxListCtrl's. Maybe it can drive you to a working direction. Here the wxListCtrl is called lstSessions and it belongs to a panel called ImporterPanel.
Hi,eranon.

I try other way to make the item obvious when it selected. Such as change its font, add underline, etc.
For now, that is all i can do.
As ONEEYEMAN said,I should go deeper.Try to change the behaviour.

Thank you.
Post Reply