I'd like to create wxFrame that won't get Destroyed when closed, so I can show them back later and also keep updating them even when they are hidden.
I tried to use SetExtraStyle(wxWS_EX_BLOCK_EVENTS)
hopping that it won't propagate the wxCloseEvent to who ever is destroying it, but it did not help.
I found with the following solution. I have to create a handler that will handle the close event and hide the frame. In this case the event is not propagated furhter. But it's a bit heavy weight becasue I need to keep tack of the handler and delete it myself.
does Anyone have a smarter solution ?
class FrameCloseHider
: public wxEvtHandler
{
public:
explicit FrameCloseHider(wxTopLevelWindow*);
void internalOnQuit(wxCloseEvent&);
wxTopLevelWindow* getFrame();
private:
wxTopLevelWindow* frame_;
};
wxTopLevelWindow* FrameCloseHider::getFrame()
{
return this->frame_;
}
void FrameCloseHider::internalOnQuit(wxCloseEvent& obj)
{
this->frame_->Hide();
}
FrameCloseHider::FrameCloseHider(wxTopLevelWindow* frame)
:frame_(frame)
{
this->frame_->Connect(
frame_->GetId(),
wxEVT_CLOSE_WINDOW,
wxCloseEventHandler(FrameCloseHider::internalOnQuit),
NULL,
this);
}