开发者

How to save the window state at wxWidgets?

I'm constructing a UI using wxWi开发者_JS百科dgets.

In my GUI, I generate a window (wxFrame class) which is accessible through pushing a bitmap button. In that window, I also perform some tasks, again pushing some bitmap buttons and diabling them etc. But I can't close and reopen that window with the state saved. I always have to re-initialize it, and this is very impractical.

How can I save the state of my window? I checked the internet, it's suggested to use wxPersistent class but this class is missing in my wxWidgets.

Thank you for any help,

Best Regards.


Instead of destroying the window every time, you can just hide it with the wxWindow::Show() member function, passing false as the argument, when you receive a wxCloseEvent. You then veto the wxCloseEvent to prevent WxWidgets from destroying your window:

// In your close handler:
if(evt.CanVeto()) // Where evt is a wxCloseEvent
{
    Show(false);  // Hide window
    evt.Veto();   // Prevent window destruction
}

This should remove it from the screen, but all the initialized parts should still be there. If you need to show it again, call the Show() method again with true.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜