Search code examples
c++eventswxwidgets

How to know when a wxFrame is closed?


I have a wxDialog where I open a wxFrame. Now I want to know when the wxFrame is closed, so I can do something in the Dialog caller [on the frame I modify a list which is present too in the dialog, and I need to update this (with a function provided by me)].

Any Ideas? I'm using C++ with wxWidgets 2.8-10

Here is the code of the function who call the frame:

OK=false;
password dialog(this,&OK); //I check the admin password, if it's correct, OK is true
dialog.ShowModal();

if (OK){
    GestionFrame* Frame = new GestionFrame(0,listaGlobal); 
    //listaGlobal is a list of names
 Frame->Show(); 
    reload(); //reload the list of names on the dialog, but reload must be called after the frame is closed (and the data is saved)

Solution

  • You'll know when the frame is closed by handling the wxCloseEvent. In the handler, do whatever to notify the "Dialog caller" that it should reload (e.g by posting an event).

    BTW, ShowModal won't return until the dialog is dismissed, and it will return a value (set by EndModal). Then you wouldn't need to mess with the OK reference.