Wrong place of panel

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
dkaip
Super wx Problem Solver
Super wx Problem Solver
Posts: 334
Joined: Wed Jan 20, 2010 1:15 pm

Wrong place of panel

Post by dkaip »

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
User avatar
doublemax
Moderator
Moderator
Posts: 19161
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Wrong place of panel

Post by doublemax »

Do you call Layout() on the topmost sizer?
Use the source, Luke!
dkaip
Super wx Problem Solver
Super wx Problem Solver
Posts: 334
Joined: Wed Jan 20, 2010 1:15 pm

Re: Wrong place of panel

Post by dkaip »

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
Super wx Problem Solver
Posts: 334
Joined: Wed Jan 20, 2010 1:15 pm

Re: Wrong place of panel

Post by dkaip »

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
Part Of The Furniture
Posts: 7480
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Wrong place of panel

Post by ONEEYEMAN »

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
Super wx Problem Solver
Posts: 334
Joined: Wed Jan 20, 2010 1:15 pm

Re: Wrong place of panel

Post by dkaip »

Hello.
Now works fine with Hide() and Show() functions.
Thank you very much.
Jim.
dkaip
Super wx Problem Solver
Super wx Problem Solver
Posts: 334
Joined: Wed Jan 20, 2010 1:15 pm

Re: Wrong place of panel

Post by dkaip »

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.
User avatar
doublemax
Moderator
Moderator
Posts: 19161
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Wrong place of panel

Post by doublemax »

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
Part Of The Furniture
Posts: 7480
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Wrong place of panel

Post by ONEEYEMAN »

Hi,
And generally speaking after "case 1" as well.

Thank you.
dkaip
Super wx Problem Solver
Super wx Problem Solver
Posts: 334
Joined: Wed Jan 20, 2010 1:15 pm

Re: Wrong place of panel

Post by dkaip »

Sorry, i forgot beak.
Code is experiment in panels.
Very few times i have use switch.
Thank you
Jim.
Post Reply