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.
dkaip
Super wx Problem Solver
Posts: 334 Joined: Wed Jan 20, 2010 1:15 pm
Post
by dkaip » Sat Feb 01, 2020 3:33 am
Hello.
I have a wxDialog with a size.
At constructor i am adding a wxPanel ...
Code: Select all
panel1= new basicForm1(this);
bSizer9->Add(panel1, 0, wxALL|wxEXPAND, 5 );
Until now all are ok. At run time i am constructing another panel and disable the panel1 and add panel2.
Code: Select all
panel2= new basicForm2(this);
bSizer9->Clear(); ... or panel1->Show(false)
bSizer9->Add(panel2, 0, wxALL|wxEXPAND, 5 );
The second panel2 take a place not in real sizer place but on left top of wxWindow.
How i can make to seeing at the right place ?
Thank you
Jim
doublemax
Moderator
Posts: 19161 Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2
Post
by doublemax » Sat Feb 01, 2020 9:46 am
Do you call Layout() on the topmost sizer?
Use the source, Luke!
dkaip
Super wx Problem Solver
Posts: 334 Joined: Wed Jan 20, 2010 1:15 pm
Post
by dkaip » Sat Feb 01, 2020 3:44 pm
I just put first the Detatch(), then add panel2 and final call the Layout() function.
All are ok.
Thank you.
Jim.
dkaip
Super wx Problem Solver
Posts: 334 Joined: Wed Jan 20, 2010 1:15 pm
Post
by dkaip » Sun Feb 02, 2020 5:16 pm
Hello
Madding two or more wxPanels in header file(private) there are showing on wxWindow, even if i Detach them and call Layout().
Code: Select all
panel1* p1= new panel1(this);
panel2* p2= new panel2(this);
How i can see only first of them? At second time i can Detach and Layout() first to see second panel.
I have try to Detach and Layout() first panel in constructor, but nothing.
Thank you
Jim.
ONEEYEMAN
Part Of The Furniture
Posts: 7480 Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine
Post
by ONEEYEMAN » Sun Feb 02, 2020 5:45 pm
Hi,
Why do you want to play with Detach()?
Just create both panels in the constructor and then hide the second one and call Layout().
When needed hide the first one and display the second one calling Layout().
Thank you.
dkaip
Super wx Problem Solver
Posts: 334 Joined: Wed Jan 20, 2010 1:15 pm
Post
by dkaip » Mon Feb 03, 2020 6:17 am
Hello.
Now works fine with Hide() and Show() functions.
Thank you very much.
Jim.
dkaip
Super wx Problem Solver
Posts: 334 Joined: Wed Jan 20, 2010 1:15 pm
Post
by dkaip » Thu Feb 06, 2020 7:51 pm
Sorry, it don’t work well.
In constructor i have.
Code: Select all
panel1= new panel(this);
panel2= new panel(this);
bSizer9->Add(panel1, 0, wxALL|wxEXPAND, 5 );
bSizer9->Add(panel2, 0, wxALL|wxEXPAND, 5 );
panel2->Hide();
bSizer9->Layout();
In a function i have
Code: Select all
panel1->Hide();
panel2->Hide();
switch (id_choice)
{
case 0:
panel1->Show();
bSizer9->Layout();
case 1:
panel2->Show();
bSizer9->Layout();
}
When have case 1 the panel2 showing up and panel1 hiding.
With choise 0 see the panel1 and panel2 after. Panel2 is not hiding.
What i am doing wrong?
Than you
Jim.
doublemax
Moderator
Posts: 19161 Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2
Post
by doublemax » Thu Feb 06, 2020 8:07 pm
If this is real code, there's a break after the "case 0" code missing.
Code: Select all
panel1->Hide();
panel2->Hide();
switch (id_choice)
{
case 0:
panel1->Show();
bSizer9->Layout();
break; <==============
case 1:
panel2->Show();
bSizer9->Layout();
}
Use the source, Luke!
ONEEYEMAN
Part Of The Furniture
Posts: 7480 Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine
Post
by ONEEYEMAN » Thu Feb 06, 2020 8:09 pm
Hi,
And generally speaking after "case 1" as well.
Thank you.
dkaip
Super wx Problem Solver
Posts: 334 Joined: Wed Jan 20, 2010 1:15 pm
Post
by dkaip » Fri Feb 07, 2020 12:56 pm
Sorry, i forgot beak.
Code is experiment in panels.
Very few times i have use switch.
Thank you
Jim.