WxWidgets application resets and loads new windows randomly

Rocco Galati
Rocco Galati used Ask the Experts™
on
I'm using WxWidgets 3.1.2 with C++ under Ubuntu to control a device which acts like a Kiosk/ATM.
I use a magnetic card reader to take inputs from the users within the first frame (ProjectMain.cpp) and then I have two other frames (SecondPage.cpp and ThirdPage.cpp) where the users can perform some actions (i.e. press buttons, insert text and so on).
At the end of this procedure, the application destroys the third frame and reloads the first frame to start a new operation with a new user.

I use wx/timer.h in order to trigger a reset function if the user do nothing for more than 5 minutes; after this time, I load the first frame again.
I put the time trigger function in the frame creation function so the timer starts as soon as the frame is loaded; I use the trigger also when some buttons are pressed.
It works very fine, but sometimes I noticed that the application resets by itself (even if T << 5 minutes) and it loads new windows in the application bar.
If I press ALT+TAB, I can see several instances of the same application and this is very strange to me.

I'm pretty sure the problem is related to the timer function, but I cannot understand how to solve it.
Can you help me, please? I need to solve this problem very urgently, but I don't know what do do.

P.S. Moreover, when only the first frame is loaded, I can see that the timer on the secondpage starts, too. But, how can this possible since Frame2 is not loded yet?

ProjectApp.cpp
#include "ProjectApp.h"

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

IMPLEMENT_APP(ProjectApp);

bool ProjectApp::OnInit()
{
    //(*AppInitialize
    bool wxsOK = true;
    wxInitAllImageHandlers();
    if ( wxsOK )
    {
    	ProjectFrame* Frame = new ProjectFrame(0);
    	Frame->Show();
    	SetTopWindow(Frame);
    }
    //*)
    return wxsOK;

}

Open in new window


ProjectMain.cpp


//helper functions
enum wxbuildinfoformat {
    short_f, long_f };

wxString wxbuildinfo(wxbuildinfoformat format)
{
    wxString wxbuild(wxVERSION_STRING);

    if (format == long_f )
    {
#if defined(__WXMSW__)
        wxbuild << _T("-Windows");
#elif defined(__UNIX__)
        wxbuild << _T("-Linux");
#endif

#if wxUSE_UNICODE
        wxbuild << _T("-Unicode build");
#else
        wxbuild << _T("-ANSI build");
#endif // wxUSE_UNICODE
    }

    return wxbuild;
}
BEGIN_EVENT_TABLE(ProjectFrame,wxFrame)
    //(*EventTable(ProjectFrame)
    //*)

END_EVENT_TABLE()

ProjectFrame::ProjectFrame(wxWindow* parent,wxWindowID id)
{
    //(*Initialize(ProjectFrame)
    Create(parent, wxID_ANY, _("Isola 01"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("wxID_ANY"));
    SetClientSize(wxSize(1323,768));
    ShowFullScreen(true);
    SetBackgroundColour(wxColour(176,253,203));
    // ..... controls... //

    Connect(ID_BUTTON2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ProjectFrame::Onbut_exitClick);
    Connect(ID_TEXTCTRL1, wxEVT_TEXT,(wxObjectEventFunction)&ProjectFrame::checkValue);
    //*)

    m_clearDataTimer.Bind(wxEVT_TIMER, &ProjectFrame::OnClearData, this);
   // thirdpage->m_clearDataTimer.Stop();
   // secondpage->m_reboot.Stop();
}
void ProjectFrame::SetPage(SecondPage* page)
{
    int w = 1024, h = 768;
//    icon_butt->SetPosition(wxPoint(w / 2 - 300, h / 2 - 150));
//    icon_butt->SetSize(600, 300);
    but_exit->SetPosition(wxPoint(w - 40, 0));
    but_exit->SetSize(40, 40);
    secondpage = page;
}
ProjectFrame::~ProjectFrame()
{
    //(*Destroy(ProjectFrame)
    //*)
}

void ProjectFrame::OnQuit(wxCommandEvent& event)
{
    Close(true);
}

void ProjectFrame::OnAbout(wxCommandEvent& event)
{
    wxString msg = wxbuildinfo(long_f);
    wxMessageBox(msg, _("Welcome to..."));
}

void ProjectFrame::Onbut_nextClick(wxCommandEvent& event)
{
    //secondpage->Show(true);
    //this->Hide();
}

void ProjectFrame::Onbut_exitClick(wxCommandEvent& event)
{
    //secondpage->Close(true);

    Close(true);
}

void ProjectFrame::Onicon_buttClick(wxCommandEvent& event)
{
   // secondpage->Show(true);
   // this->Hide();
}
void ProjectFrame::OnTextCtrl1Text1(wxCommandEvent& event)
{
}


void ProjectFrame::checkValue(wxCommandEvent& event)
{
    printf("START TIMER\n");
    m_clearDataTimer.StartOnce(3000);

}

void ProjectFrame::OnClearData(wxTimerEvent&)
    {

    printf("accesso: %d", accesso);
    identificazione->Hide();
    assistenza->Hide();
    printf("TIMER TERMINATO!\n");
    wxString stringa_tessera = tessera->GetValue();
    if (!tessera->IsEmpty()){
    wxString number = stringa_tessera.Mid(1, 16);  // Mid starts at offset 1 and takes 16 chars
    wxString rest = stringa_tessera.Mid(17);                         // consider the leading %
    surname = rest.BeforeFirst(wxUniChar(' '));   // now it should be "URSO"
    rest = rest.AfterFirst(wxUniChar(' '));
    // %URSMCC84R04E815LURSO  MARCO_ò8038001605011036724_

    int counter_number = static_cast<int>(number.Length());
    int counter_name = static_cast<int>(name.Length());
    int counter_surname = static_cast<int>(surname.Length());
    int counter_rest = static_cast<int>(rest.Length());

    printf("CF: %d\n", counter_number);
    printf("name: %d\n", counter_name);
    printf("surname: %d\n", counter_surname);
    printf("rest: %d\n", counter_rest);

    int p = '%';
    int dash = '_';

    if ( (counter_number == 16) && (counter_name > 2) && (counter_surname > 2) ){
        int check_cf=0;
        identificazione->Hide();
        assistenza->Hide();
        m_clearDataTimer.Stop();
        tessera->Clear();
        Connection conn(false);
        conn.connect("isola", "localhost", "root", "isola");
        Query query = conn.query();

        /* Now SELECT */
        query << "SELECT * FROM Utenti";
        StoreQueryResult ares = query.store();
        wxString mystring;

        for (size_t i = 0; i < ares.num_rows(); i++){
        if( (ares[i]["CF"]) == number.ToStdString()){
        // mystring << (const char *)ares[i]["CF"];
        if(accesso == 0){

         printf("apro la porta prima del thread\n");
         pthread_create(&thread_porta, NULL, porta, NULL);
              accesso=1;
        } else if (accesso == 1){
        check_cf=1;
        name = rest.BeforeFirst(wxUniChar('_'));
        char buf[100];
        strcpy( buf, (const char*)number.mb_str(wxConvUTF8) ); // buf will now contain "Hello world"
        printf("Ecco: %s\n", buf);
        rest_ctrl->ChangeValue("OK");
        secondpage = new SecondPage(nullptr, 1);
        strcpy(secondpage->codice_fiscale, buf);
        secondpage->user->SetLabel(name);
        secondpage->Refresh();
        secondpage->Update();
        // start the timer to set the timemout for the second frame
        secondpage->m_reboot.StartOnce(360000);
        secondpage->Show(true);
        this->Hide();
        accesso=0;
        break;
        }
        }
        }
     printf("\nOK\n"); //
        if (check_cf == 0 && accesso == 0) {
        printf("Errore1\n");
        identificazione->Show(TRUE);
        assistenza->Show(TRUE);
        tessera->Clear();
        }
        }

    else {
        printf("Errore2\n");
        identificazione->Show(TRUE);
        assistenza->Show(TRUE);
        tessera->Clear();
        //m_clearDataTimer.Stop();
    }
    }

    }

Open in new window


Secondpage.cpp
BEGIN_EVENT_TABLE(SecondPage,wxFrame)
	//(*EventTable(SecondPage)
	//*)
END_EVENT_TABLE()
//void SecondPage::SetPage(ProjectFrame* page)
void SecondPage::SetPage(ThirdPage* page)
{
    int w = 1024, h = 768;
    but_prev->SetPosition(wxPoint(w / 2 - 300, h / 2 - 150));
    but_prev->SetSize(600, 300);
    but_exit->SetPosition(wxPoint(w - 40, 0));
    but_exit->SetSize(40, 40);
    thirdpage = page;
    thirdpage->Refresh();
    thirdpage->Update();
}
SecondPage::SecondPage(wxWindow* parent,wxWindowID id)
{
	//(*Initialize(SecondPage)
	Create(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("wxID_ANY"));
	SetClientSize(wxSize(1314,769));
	SetBackgroundColour(wxColour(175,253,202));
	but_prev = new wxButton(this, ID_BUTTON1, _("Second Page"), wxPoint(1128,232), wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON1"));
	but_prev->Hide();
	but_exit = new wxButton(this, ID_BUTTON3, _("Exit"), wxPoint(696,0), wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON3"));
	but_exit->Hide();
	welcome = new wxStaticText(this, ID_STATICTEXT2, _("Ciao"), wxPoint(392,24), wxSize(136,56), 0, _T("ID_STATICTEXT2"));
	welcome->Hide();
	wxFont welcomeFont(26,wxFONTFAMILY_SWISS,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_BOLD,false,_T("Sans"),wxFONTENCODING_DEFAULT);
	welcome->SetFont(welcomeFont);
	user = new wxStaticText(this, ID_STATICTEXT3, _("Utente"), wxPoint(488,24), wxSize(144,88), 0, _T("ID_STATICTEXT3"));
	user->Hide();
	wxFont userFont(26,wxFONTFAMILY_SWISS,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_BOLD,false,_T("Sans"),wxFONTENCODING_DEFAULT);
	user->SetFont(userFont);
	plastica = new wxBitmapButton(this, ID_BITMAPBUTTON2, wxBitmap(wxImage(_T("/home/robodyne/Project/pics/plastica256x256-did.png"))), wxPoint(48,80), wxDefaultSize, wxBU_AUTODRAW, wxDefaultValidator, _T("ID_BITMAPBUTTON2"));
	vetro = new wxBitmapButton(this, ID_BITMAPBUTTON3, wxBitmap(wxImage(_T("/home/robodyne/Project/pics/vetro256x256-did.png"))), wxPoint(376,80), wxDefaultSize, wxBU_AUTODRAW, wxDefaultValidator, _T("ID_BITMAPBUTTON3"));
	carta = new wxBitmapButton(this, ID_BITMAPBUTTON4, wxBitmap(wxImage(_T("/home/robodyne/Project/pics/carta256x256-did.png"))), wxPoint(704,80), wxDefaultSize, wxBU_AUTODRAW, wxDefaultValidator, _T("ID_BITMAPBUTTON4"));
	pannolini = new wxBitmapButton(this, ID_BITMAPBUTTON5, wxBitmap(wxImage(_T("/home/robodyne/Project/pics/pannolini256x256-did.png"))), wxPoint(48,392), wxDefaultSize, wxBU_AUTODRAW, wxDefaultValidator, _T("ID_BITMAPBUTTON5"));
	organico = new wxBitmapButton(this, ID_BITMAPBUTTON1, wxBitmap(wxImage(_T("/home/robodyne/Project/pics/organico256x256-did.png"))), wxPoint(376,392), wxDefaultSize, wxBU_AUTODRAW, wxDefaultValidator, _T("ID_BITMAPBUTTON1"));
	secco = new wxBitmapButton(this, ID_BITMAPBUTTON6, wxBitmap(wxImage(_T("/home/robodyne/Project/pics/secco256x256-did.png"))), wxPoint(704,392), wxDefaultSize, wxBU_AUTODRAW, wxDefaultValidator, _T("ID_BITMAPBUTTON6"));
	secco->Hide();
	selezione_tipologia = new wxStaticText(this, ID_STATICTEXT1, _("Seleziona il tipo di conferimento"), wxPoint(200,8), wxDefaultSize, 0, _T("ID_STATICTEXT1"));
	wxFont selezione_tipologiaFont(26,wxFONTFAMILY_SWISS,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_BOLD,false,_T("Sans"),wxFONTENCODING_DEFAULT);
	selezione_tipologia->SetFont(selezione_tipologiaFont);
	cancel = new wxBitmapButton(this, ID_BITMAPBUTTON7, wxBitmap(wxImage(_T("/home/robodyne/Project/pics/cancel-34x34.png"))), wxPoint(8,8), wxDefaultSize, wxBU_AUTODRAW, wxDefaultValidator, _T("ID_BITMAPBUTTON7"));

//	Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&SecondPage::OnButton1Click);
	Connect(ID_BUTTON3,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&SecondPage::Onbut_exitClick);
	Connect(ID_BITMAPBUTTON2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&SecondPage::OnplasticaClick);
	Connect(ID_BITMAPBUTTON3,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&SecondPage::OnvetroClick);
	Connect(ID_BITMAPBUTTON4,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&SecondPage::OnalluminioClick);
	Connect(ID_BITMAPBUTTON5,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&SecondPage::OnpannoliniClick);
	Connect(ID_BITMAPBUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&SecondPage::OnorganicoClick);
	Connect(ID_BITMAPBUTTON6,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&SecondPage::OnseccoClick);
	Connect(ID_BITMAPBUTTON7,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&SecondPage::OncancelClick);
	//*)

	m_reboot.Bind(wxEVT_TIMER, &SecondPage::Reboot, this);

     if (get_day_of_year() == 2 || get_day_of_year() == 4){
        secco->Show();
     }

//    wxSound* sound = new wxSound(wxT("/home/robodyne/Downloads/prova2.wav"),false);
//	sound->Play(wxT("/home/robodyne/Downloads/prova2.wav"),wxSOUND_ASYNC);
//    wxLog::AddTraceMask("sound");
  pthread_create(&thread, NULL, wait, NULL);
}

SecondPage::~SecondPage()
{
	//(*Destroy(SecondPage)
	//*)
}




void SecondPage::Onbut_exitClick(wxCommandEvent& event)
{
    thirdpage->Close(true);
    Close(true);
}

void SecondPage::OnButton2Click(wxCommandEvent& event)
{
}

void SecondPage::OnBitmapButton1Click(wxCommandEvent& event)
{
}
void SecondPage::OnplasticaClick(wxCommandEvent& event)
{
   // pthread_cancel(thread);
     // stop playing
    libvlc_media_player_stop(mp);
    // free the media_player
    libvlc_media_player_release(mp);
    libvlc_release(inst);
    thirdpage = new ThirdPage(nullptr, 2);
    thirdpage->selezione="plastica";
    strcpy(thirdpage->codice_fiscale, codice_fiscale);
    thirdpage->tipologia_rifiuto->SetLabel(thirdpage->selezione);
    thirdpage->Refresh();
    thirdpage->Update();
    thirdpage->m_reboot.StartOnce(600000);
    thirdpage->Show(true);
    this->Hide();
}
void SecondPage::OncancelClick(wxCommandEvent& event)
{
    firstpage = new ProjectFrame(NULL, -1);
    firstpage ->SetClientSize(wxSize(1323,768));
	firstpage->Show(true); //show it
	this->Destroy(); //and destroy page3
	//then you do not need to modify destructors.
}

void SecondPage::Reboot(wxTimerEvent&){
    printf("Reboot the whole system! Timeout! second page\n");
    m_reboot.Stop();
    firstpage = new ProjectFrame(nullptr, -1);
    firstpage ->SetClientSize(wxSize(1323,768));
    firstpage->ShowFullScreen(true);
	firstpage->Show(true); //show it
	this->Destroy(); //and destroy page3
	
}

Open in new window


ThirdPage.cpp

BEGIN_EVENT_TABLE(ThirdPage,wxFrame)
	//(*EventTable(ThirdPage)
	//*)
END_EVENT_TABLE()
void ThirdPage::SetPage(ProjectFrame* page)
{
    int w = 1024, h = 768;
//    button_home->SetPosition(wxPoint(w / 2 - 300, h / 2 - 150));
//    button_home->SetSize(600, 300);
//    button_exit->SetPosition(wxPoint(w - 40, 0));
//    button_exit->SetSize(40, 40);
    firstpage = page;
}

ThirdPage::ThirdPage(wxWindow* parent, wxWindowID id)
{
	//(*Initialize(ThirdPage)
	Create(parent, wxID_ANY, _("Frame"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE|wxNO_BORDER|wxTRANSPARENT_WINDOW, _T("wxID_ANY"));
	SetClientSize(wxSize(1384,932));
	SetBackgroundColour(wxColour(175,253,202));
	// ... several controls.. //
	Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ThirdPage::Onbutton_homeClick);
	Connect(ID_BUTTON2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ThirdPage::Onbutton_exitClick);
	Connect(ID_BITMAPBUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ThirdPage::OnsecchioClick);
	Connect(ID_BITMAPBUTTON2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ThirdPage::OnbustaClick);
	Connect(ID_BUTTON3,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ThirdPage::OnButton1Click2);
	Connect(ID_BITMAPBUTTON3,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ThirdPage::OnbilanciaClick);
	Connect(ID_BITMAPBUTTON4,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ThirdPage::OnBitmapButton1Click);
	Connect(ID_BITMAPBUTTON5,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ThirdPage::OnBitmapButton2Click);
	Connect(ID_BITMAPBUTTON6,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ThirdPage::OnBitmapButton1Click1);
	Connect(ID_BUTTON4,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ThirdPage::Onconferimento_completatoClick);
	Connect(ID_BUTTON5,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ThirdPage::OnricevutaClick);
	//*)
    m_clearDataTimer.Bind(wxEVT_TIMER, &ThirdPage::Shutdown, this);
    m_reboot.Bind(wxEVT_TIMER, &ThirdPage::Reboot, this);
    pthread_create(&thread_scelta, NULL, mp3_contenitore, NULL);

}

ThirdPage::~ThirdPage()
{
	//(*Destroy(ThirdPage)
	//*)
}
void ThirdPage::Onbutton_exitClick(wxCommandEvent& event)
{
    firstpage->Close(true);
    this->Close(true);
}

void ThirdPage::OnselezioneText(wxCommandEvent& event)
{

}

void ThirdPage::OnButton1Click1(wxCommandEvent& event)
{

}

void ThirdPage::OnToggleButton1Toggle(wxCommandEvent& event)
{

}

void ThirdPage::OnsecchioClick(wxCommandEvent& event)
{
      // stop playing
    libvlc_media_player_stop(mp_scelta);
    // free the media_player
    libvlc_media_player_release(mp_scelta);
    libvlc_release(inst_scelta);
    contenitore=0;
    tipologia_conferimento->Show(false);
    tipologia_rifiuto->Show(false);
    secchio_o_busta->Show(false);
    secchio->Show(false);
    indicazione_bilancia->Show(true);
    testo_pesata->Show(true);
    bilancia->Show(true);
    busta->Hide();
    arrow_selezione->Show();
    arrow_conferimento->Hide();

      // load the vlc engine
    inst_scelta = libvlc_new(0, NULL);
        // create a new item
    m_scelta = libvlc_media_new_path(inst_scelta, "/home/robodyne/Project/audio/pesata.mp3");
    // create a media play playing environment
    mp_scelta = libvlc_media_player_new_from_media(m_scelta);
    // no need to keep the media now
    libvlc_media_release(m_scelta);

    // play the media_player
    libvlc_media_player_play(mp_scelta);

    m_reboot.StartOnce(6000000);
}
void ThirdPage::OnBitmapButton1Click(wxCommandEvent& event)
{
    secondpage = new SecondPage(nullptr, 2);
    secondpage->Show(true);
    this->Hide();
}

void ThirdPage::OnBitmapButton2Click(wxCommandEvent& event)
{
    secchio->Show();
    busta->Show();
    arrow_conferimento->Hide();
    bilancia->Hide();
    indicazione_bilancia->Hide();
    testo_pesata->Hide();
    tipologia_conferimento->Show();
    secchio_o_busta->Show();
    arrow_selezione->Hide();
    arrow_conferimento->Show();
    tipologia_rifiuto->Show();

}

void ThirdPage::OncancelClick(wxCommandEvent& event)
{
    firstpage = new ProjectFrame(NULL, -1);
    firstpage ->SetClientSize(wxSize(1323,768));
	firstpage->Show(true); //show it
	this->Destroy(); //and destroy page3
	//then you do not need to modify destructors.
}

void ThirdPage::OnBitmapButton1Click1(wxCommandEvent& event)
{
     firstpage = new ProjectFrame(NULL, -1);
    firstpage ->SetClientSize(wxSize(1323,768));
	firstpage->Show(true); //show it
	this->Destroy(); //and destroy page3
	//then you do not need to modify destructors.
}
void ThirdPage::Onconferimento_completatoClick(wxCommandEvent& event)
{

  // stop playing
    libvlc_media_player_stop(mp_scelta);
    // free the media_player
    libvlc_media_player_release(mp_scelta);
    libvlc_release(inst_scelta);


pistoni_plastica(0);
pistoni_secco(0);
pistoni_carta(0);
pistoni_organico(0);
pistoni_pannolini(0);
pistoni_vetro(0);
 inst_scelta = libvlc_new(0, NULL);
        // create a new item
    m_scelta = libvlc_media_new_path(inst_scelta, "/home/robodyne/Project/audio/stampa-ricevuta.mp3");
    // create a media play playing environment
    mp_scelta = libvlc_media_player_new_from_media(m_scelta);
    // no need to keep the media now
    libvlc_media_release(m_scelta);
    // play the media_player
    libvlc_media_player_play(mp_scelta);
ricevuta->Show();
conferimento_completato->Hide();
printf("START TIMER\n");
m_clearDataTimer.StartOnce(40000);

}
void ThirdPage::Shutdown(wxTimerEvent&){

    printf("Spengo pistoni\n");
    pistoni_plastica(2);
    pistoni_secco(2);
    pistoni_carta(2);
    pistoni_organico(2);
    pistoni_pannolini(2);
    pistoni_vetro(2);
    firstpage = new ProjectFrame(nullptr, 1);
    firstpage ->SetClientSize(wxSize(1323,768));
    firstpage->ShowFullScreen(true);
	firstpage->Show(true); //show it
	this->Destroy(); //and destroy page3
	//then you do not need to modify destructors.
}

void ThirdPage::Ontermina_conferimentoClick(wxCommandEvent& event)
{
    firstpage = new ProjectFrame(NULL, -1);
    firstpage ->SetClientSize(wxSize(1323,768));
	firstpage->Show(true); //show it
	this->Destroy(); //and destroy page3
	//then you do not need to modify destructors.
}

void ThirdPage::Reboot(wxTimerEvent&){
    printf("Reboot the whole system! Timeout!\n");
    pistoni_plastica(2);
    pistoni_secco(2);
    pistoni_carta(2);
    pistoni_organico(2);
    pistoni_pannolini(2);
    pistoni_vetro(2);
    firstpage = new ProjectFrame(nullptr, 1);
    firstpage ->SetClientSize(wxSize(1323,768));
    firstpage->ShowFullScreen(true);
	firstpage->Show(true); //show it
	this->Destroy(); //and destroy page3
	//then you do not need to modify destructors.
}

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial