wxTreeCtrl and wxSplitterWindow

If you are using wxDev-C++ for your wxWidgets design, please ask your questions here instead of in IDE Related.
Post Reply
Earned a small fee
Earned a small fee
Posts: 22
Joined: Sat Jun 18, 2011 11:37 pm

wxTreeCtrl and wxSplitterWindow

Post by Rachel » Tue Jul 19, 2011 5:44 pm

I have some problems, how to use the wxSplitterWindow properly.
I have a wxframe and all my elements are on a wxPanel. It should be splitted vertically. I want to show on the left side a TreeCtrl to organize data and the already designed frame on the right.
The widths of the two windows should not be static.
It's driving me crazy that it's everywhere in windows and I don't know how to do it..

Earned some good credits
Earned some good credits
Posts: 113
Joined: Sat Sep 24, 2011 9:32 pm
Location: Poland

Re: wxTreeCtrl and wxSplitterWindow

Post by jgrzybowski » Sat Sep 24, 2011 10:01 pm

I am sorry but I do not have any experience in using wxSplitterWindow. But you can try to use wxBoxSizer:
1) put on the wxPanel object directly one component wxBoxSizer;
2)in the properties set the Orientation of wxBoxSizer (wxHorizontal or wxVertical);
3)then put all your elements on the wxBoxSizer;
4)in the properties set Width/Hight of the main elements - for example: window has 1000 width so wxTreeCtrl on the left can have 275 (about 30%) and some frame on the right can have 675 (about 70%)
5)in the properties of both main elements set Alignment - wxExpand on True;
6)in the properties of both main elements set Stretch Factor on value 1;
Result should be following: when user change the size of window, these two main elements also have changed the size but in the same scale about 30%/70%. Stretch Factor 1 means change size of component together with main window.

Site Admin
Site Admin
Posts: 3988
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: wxTreeCtrl and wxSplitterWindow

Post by DavidHart » Sun Sep 25, 2011 7:47 am


I think the OP wanted the user to be able to drag the dividing sash, which isn't possible just with sizers.

If she hadn't posted in the wrong forum (it should have been in 'C++') someone would very likely have mentioned that there's a sample that comes with the wxWidgets source, 'splitter', that demonstrates how to use wxSplitterWindow. Also that you can't put a toplevel window (e.g. wxFrame) inside a splitterwindow, so she'd need to use the wxPanel that already contains the elements. The splitterwindow then goes in frame, of course; either direct or preferably into (the sizer of) a wxPanel that's the frame's only child control.



Post Reply