wxsimplebook doesn't work after inserting panel/page from another source file 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
failedone
In need of some credit
In need of some credit
Posts: 5
Joined: Fri Jul 16, 2021 6:53 pm

wxsimplebook doesn't work after inserting panel/page from another source file

Post by failedone »

Hi,

I have a problem when trying to incorporate a panel written in another source file to my mainFrame source file.
if I try to add pages into my wxsimplebook with panels written in mainFrame, it works fine.
for example, I declare new panel and add it on my simplebook and when I press button A, the result is like this:
Capture2red.JPG
Capture2red.JPG (11.34 KiB) Viewed 1632 times
when I add to simplebook a panel I made (with bunch of button inside it) from different source file, this happen when I press either button A or B:
Capture1pan.JPG
Capture1pan.JPG (11.75 KiB) Viewed 1632 times
seems like the panel frame i made from another source file stuck on top of simplebook in main frame?
but there is no problem when I add panels as many as i wanted as long as it was made inside main frame
I wrote the code in codeblock (windows 10) using wxsmith.
source files cointaining below:
App.h
App.cpp
Main.h
Main.cpp // implementation of main frame
ATool.h
ATool.cpp // implementation of panel with bunch of buttons that i intend to add into simplebook in main frame
here is sample of my codeblock project:
changingtoolbar.zip
(963.57 KiB) Downloaded 43 times
surely, I can solve it by making panels (with bunch of button inside it) in the same source file (main frame) but its not ideal when project getting bigger.

I dont see where is my mistake, it should have worked.
been searching for this topic but no luck, hopefully someone in here has the solution.
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxsimplebook doesn't work after inserting panel/page from another source file

Post by doublemax »

The code being in another source file has nothing to do with it.

Is the sizer code completely generated from C:B or did you edit it? Because there is at least one error in it:

Code: Select all

PanelSimpBook->SetSizer(BoxSimp);
....
BoxSizer1->Add(BoxSimp, 0, wxALL|wxALIGN_TOP, 5);
A sizer (BoxSimp) that's assigned to a window, can not be inserted into another sizer. Try removing the second line.

Not really an error, but notable: In the code as it is, both BoxSimp and PanelSimpBook are not needed. You could just insert the wxSimplebook ("simp") into BoxSizer1. But if you intent to add more controls to PanelSimpBook and BoxSimp in the future, it's ok.
Use the source, Luke!
Post Reply