Question about multiple frame

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
giuseppe.sportelli
In need of some credit
In need of some credit
Posts: 8
Joined: Sat May 09, 2020 12:47 pm

Question about multiple frame

Post by giuseppe.sportelli » Sat May 09, 2020 1:38 pm

Hello, i have a problem with my application.
I have two frame called Archvio_AppFrame and Finestra_Visualizza.
The Application starts with first frame.
In the first frame i have many controls, and when i press a button, i wish hide first frame and show the second.
My code:

Code: Select all

void App_ArchivioFrame::OncmdvisClick(wxCommandEvent& event)
{
    Iconize();
    childFrame->Show(true);
    childFrame = new Finestra_Visualizza(parentFrame,wxID_ANY,wxPoint(100,100),wxSize(400,400));
}
Definition of childFrame and parentFrame pointer are written in the code

Code: Select all

#include "App_ArchivioApp.h"


//(*AppHeaders
#include "App_ArchivioMain.h"
#include "Finestra_Visualizza.h"
#include <wx/image.h>
//*)

IMPLEMENT_APP(App_ArchivioApp);
App_ArchivioFrame *parentFrame;
Finestra_Visualizza *childFrame;
bool App_ArchivioApp::OnInit()
{
    //(*AppInitialize
    bool wxsOK = true;
    wxInitAllImageHandlers();
    if ( wxsOK )
    {
    	parentFrame = new App_ArchivioFrame(0);

    	parentFrame->Show();
    	SetTopWindow(parentFrame);



    }
    //*)
    return wxsOK;

}
Now when i press button application quit.
Where do i mistake ?

User avatar
doublemax
Moderator
Moderator
Posts: 14786
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Question about multiple frame

Post by doublemax » Sat May 09, 2020 2:20 pm

Code: Select all

    childFrame->Show(true);
    childFrame = new Finestra_Visualizza(parentFrame,wxID_ANY,wxPoint(100,100),wxSize(400,400));
Change the order. First create the frame, then Show it.

Also, this code creates a new frame each time the user presses the button. Is that what you want?
Use the source, Luke!

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4058
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Question about multiple frame

Post by ONEEYEMAN » Sat May 09, 2020 2:36 pm

Hi,
Do you disable the button after the user clicks it?
Otherwise you should check if the second frame pointer is valid and create it if it isn't.

Thank you.

giuseppe.sportelli
In need of some credit
In need of some credit
Posts: 8
Joined: Sat May 09, 2020 12:47 pm

Re: Question about multiple frame

Post by giuseppe.sportelli » Sat May 09, 2020 2:47 pm

Thank
i've written code in mistake order
First i create the frame and after i show it.
No i don't disabile button.
childframe is invoked from butto event in parentframe.
When i click application iconize and ends.

Post Reply