If you are still looking for some solution, I can advise nonmodal wxDialog. First window is main window - wxFrame object, but second window you can use wxDialog object (wxDev->File->New wxDialog). You need to include header of second window inside of first window cpp file (TestTwoWindowsFrm.cpp):
Pointer of second window object should be defined as a global variable outside of any function (TestTwoWindowsFrm.cpp):
Your button function should shows second dialog as a nonmodal to have two windows active and ready to use for user (TestTwoWindowsFrm.cpp):
Code: Select all
/*
* buttonSecondWindowClick
*/
void TestTwoWindowsFrm::buttonSecondWindowClick(wxCommandEvent& event)
{
dialogSecondWindow = new SecondDlg(NULL);
dialogSecondWindow->Show(); //do not use ShowModal()
return;
}
Inside of second dialog cpp file define function to change the text (SecondDlg.cpp):
Code: Select all
void SecondDlg::ChangeTextInSecondWindow(wxString NewText)
{
statictextTextInSecondDlg->SetLabel(NewText);
return;
}
this function above should be declear in header file as a public (SecondDlg.h):
Code: Select all
public:
void ChangeTextInSecondWindow(wxString NewText);
And now you can define button function in first window to change text in second one (TestTwoWindowsFrm.cpp):
Code: Select all
/*
* buttonChangeTextSecondWinClick
*/
void TestTwoWindowsFrm::buttonChangeTextSecondWinClick(wxCommandEvent& event)
{
dialogSecondWindow->ChangeTextInSecondWindow(wxT(" New text "));
return;
}
In my short programm it works. Small problem becomes when you close first main window with out closing second nonmodal window. That is why you should define also public close function for second one and call this function before main window has been destroyed:
(TestTwoWindowsFrm.cpp):
Code: Select all
#include "SecondDlg.h"
SecondDlg *dialogSecondWindow;
//...
void TestTwoWindowsFrm::OnClose(wxCloseEvent& event)
{
dialogSecondWindow->CloseMe();
Destroy();
return;
}
/*
* buttonCloseClick
*/
void TestTwoWindowsFrm::buttonCloseClick(wxCommandEvent& event)
{
dialogSecondWindow->CloseMe();
Destroy();
return;
}
/*
* buttonSecondWindowClick
*/
void TestTwoWindowsFrm::buttonSecondWindowClick(wxCommandEvent& event)
{
dialogSecondWindow = new SecondDlg(NULL);
dialogSecondWindow->Show();
return;
}
/*
* buttonChangeTextSecondWinClick
*/
void TestTwoWindowsFrm::buttonChangeTextSecondWinClick(wxCommandEvent& event)
{
dialogSecondWindow->ChangeTextInSeconWindow(wxT(" New text "));
return;
}
(SecondDlg.cpp):
Code: Select all
void SecondDlg::ChangeTextInSeconWindow(wxString NewText)
{
statictextTextInSecondDlg->SetLabel(NewText);
return;
}
void SecondDlg::CloseMe()
{
Destroy();
return;
}