I am trying to make my app size (and maybe position too) restored when restarting.
For the moment, I save 2 data:
* if the frame is maximized,
* the height/width of the frame before it was maximized (these info are correct at saving time).
When I restore my app, I first set the size of the frame (in all cases), then I call Maximize(true) if the frame was maximized.
Everything seems to work except when I un-maximize the frame (by clicking on the "maximize" button, or double click on the app title bar). It does not restore to the size I set.
Is this normal? How can I force the "default restore" size when un-maximizing?
Here is a piece of my code:
Code: Select all
// header
class MyFrame: public wxFrame
{
public:
// constructor
MyFrame (/*params*/);
// event handlers
void OnSize (wxSizeEvent &evt);
// ...
protected:
wxSize frame_size;
};
// implementation
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_SIZE (MyFrame::OnSize)
// ...
END_EVENT_TABLE ()
MyFrame::MyFrame (/*params*/)
{
// ...
if (app_options.last_size is not set)
frame_size = wxSize (800, 600);
else
frame_size = app_options.last_size;
SetSize (frame_size);
if (app_options.was_maximized)
Maximize (true);
// ...
}
MyFrame::~MyFrame
{
app_options.last_size = frame_size;
app_options.was_maximized = IsMaximized ();
// ...
}
void MyFrame::OnSize (wxSizeEvent &evt)
{
if (!IsMaximized())
frame_size = evt.GetSize();
evt.Skip();
wxFrame::OnSize (evt);
}
I also use wxAUI, 0.9.2 with a patch of mine (to allow size events to be processed by my frame, because the frame manager eats them).
Thanks for your help.