Reputation: 1
I am an MFC beginner. I found this little error when I created a simple Form Based MFC application (using the VS2012), but I don't know how to fix it.
The default program seems to remember the program's previous state, i.e. window position, window size (maximized or minimized). So when the program is reopened, the program will be restored to the state that it was closed last time.
Here are the steps to find the bug:
1) open the program
2) maximize the window
3) close the program
4) re-launch the program
What happened is, when I re-launch the program, although the window is not in a maximized state, the 'maximize' button at top right window does not show correctly. Instead of showing a maximized icon, it now shows a 'restore down' icon...
How do I fix this bug?
Moreover, how do I disable this function so the program can always be launched at a specific position and size, regardless its previous closing state?
Using m_pMainWnd->MoveWindow(x, y, Width, Height) function before m_pMainWnd->ShowWindow(SW_SHOW);?
Upvotes: 0
Views: 494
Reputation: 15355
When I create a default sample with a CFormView the OnInitialUpdate contains the line ResizeParentToFit();
Remove it, and the application is maximized as the previous state. ResizeParentToFit, does exactly what the name says. It resizes the parent window so the parent window fits exactly the form you created.
If you don't want that the window placement is restored at all, set the variable CWinApEx::m_bLoadWindowPlacement to FALSE. By default this flag is set to TRUE!
Upvotes: 1