Our application stores all window locations, and user configurations inside a persistent variable system when the application is quit, with restoring of all window positions and configurations as they were when the application was last quit with each launch.
I am adding logic that determines at launch when a window is being restored to a position no longer visible, due to a monitor rotating or being removed. I can do this repositioning and resizing fine with logic such as this:
Code: Select all
mp_mainframe->Show(true);
mp_mainframe->Maximize(false);
// how the default window position is calculated when app runs for first time:
int x, y, w, h;
wxClientDisplayRect(&x, &y, &w, &h);
int width = cx_round((cx_real)0.75*(cx_real)w);
int height = cx_round((cx_real)0.75*(cx_real)h);
if (height > 915)
height = 915; // will only carry forward when a new app config is being created
int left = (w - width) / 2;
int top = (h - height) / 2;
mp_mainframe->SetPosition( wxPoint(left,top) );
mp_mainframe->SetClientSize( width, height );
mp_mainframe->Refresh();