Native windows system theme for tree control

CodeLite installation/troubleshooting forum
jvenema
CodeLite Curious
Posts: 7
Joined: Wed Jun 14, 2017 8:23 pm
Genuine User: Yes
IDE Question: C++
Contact:

Native windows system theme for tree control

Post by jvenema »

I'm a happy user of the Codelite IDE for developing a cross platform application with wxWidgets. When using the wxTreeCrtl I get on windows the more old fashioned style with the + and minus and the dotted lines. I tried to use the more modern style by usingthe wxTR_TWIST_BUTTONS style. I tried to call the 'EnableSystemTheme()' method on the control, but all in vain.
When using the Codelite IDE, which also using wxWidgets on windows, the trees do have the more modern look. So I cloned the Git repository of Codelite and looked in the source files on how it is done there.
There I extracted the following piece of code:

Code: Select all

#ifdef __WXMSW__
#include <Uxtheme.h>
#endif

void MSWSetNativeTheme(wxWindow* win, const wxString& theme = wxT("Explorer"))
{
#ifdef __WXMSW__
    SetWindowTheme((HWND)win->GetHWND(), theme.c_str(), NULL);
#endif    
}
[/color]

And after constructing the tree control I pass its pointer to this function. I even used the debugger to check the return code of SetWindowTheme which was 0, so that seems ok, but still all looks the same old way.
Since it does seem to work in Codelite, the question is, what do I miss? Must there be some mystic initialisation call?
I use wxWidgets 3.1 and applied 3 patches on it that i found with "brew edit wxMac"
I further build the wxWidgets sources for the 3 platforms with the settings as mentioned on the Codelite Wiki about how to build Codelite. I assumed that if that it is good for building Codelite, it is also good for my application.
Thus any hints on how to get the modern look on tree control under windows are welkom.
I can not stress the good work of Codelite, it is a real gem!
User avatar
eranif
CodeLite Plugin
Posts: 6367
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Native windows system theme for tree control

Post by eranif »

I think that you also need a proper resource file (check code_parser.rc in CodeLite source tree)
Make sure you have read the HOW TO POST thread
jvenema
CodeLite Curious
Posts: 7
Joined: Wed Jun 14, 2017 8:23 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Native windows system theme for tree control

Post by jvenema »

Thanks I that is a quick reply! Just back from my pizza and the reply is there! I will have a look at your suggestion, any hints or pointers on how to load it. Up to now my controls are made in code, so without external resources. I guess it will be one of the next topics I dive into. Coming from visual studio and MFC stuff, there is a lot to learn. Within Visual studio you edit the resources, you saw them as files in the directory structure, but the loading was handled by VS for you,I guess this works a little bit different.
User avatar
eranif
CodeLite Plugin
Posts: 6367
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Native windows system theme for tree control

Post by eranif »

If you are using CodeLite as your IDE, just add a .rc file to your project and add the following content:

Code: Select all

#include "wx/msw/wx.rc"
#include "winuser.h"

#ifdef WIN64
    1 24 "wx/msw/amd64.manifest"
#else
    1 24 "wx/msw/wx.manifest"
#endif
CodeLite will compile and link this file for you so there is nothing else for you to do

Eran
Make sure you have read the HOW TO POST thread
jvenema
CodeLite Curious
Posts: 7
Joined: Wed Jun 14, 2017 8:23 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Native windows system theme for tree control

Post by jvenema »

It worked!! The TreeCtrl now has the modern look.The issue is that I started with an empty project and copied stuff from other try-out projects over. Therefor there was no resource file. Other projects created with the wizard did already have it automatically.
I have one other thing to resolve, at the project settings the checkbox "This program is a GUI application" is enabled, so no wrapper console is needed. This works fine for OSX and Ubuntu, but on windows there is always a wrapper console. Both when started from Codelite, or by double clicking on the executable in explorer.
Any Idea, how to tackle this issue?
jvenema
CodeLite Curious
Posts: 7
Joined: Wed Jun 14, 2017 8:23 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Native windows system theme for tree control

Post by jvenema »

I've found out the issue, had to do that original I created the project on another OS. When a project was created on windows, I saw a different setting. It has to do with the -mwindows linker flag. When this was added to the project, the wrapper was gone. Have to see how to work with one source tree and to have different project settings for each platform.
Post Reply