Window Size Changes when I open a file(File->Open)

I have an SDI application, where the view class is derieved from CFormView.  On startup, I maximize the window, but when I open a file (CWinApp::OnFileOpen), the window returns to the size specified in the resource file.  I would like for the window to remain the same size as before the File Open (Maximized or not).  Any ideas?

This code is in the InitInstance() function of the CWinApp derived class to maximize the window:


Thanks for your help!
Who is Participating?
PriyeshConnect With a Mentor Commented:
in the OnInitialUpdate in your FormView derived class, if there is a line ResizeParentToFit, comment it.
Maybe you can specify in your Mainframe how large you'd like it to be, then it won't change its size later on.

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
     if( !CFrameWnd::PreCreateWindow(cs) )
          return FALSE; = ::GetSystemMetrics(SM_CYSCREEN); = ::GetSystemMetrics(SM_CXSCREEN);
    cs.y = 0;
    cs.x = 0;

     return TRUE;

It is not the maximizing effect though...(it just get the screen size and set the application size = screen size) Would it serve your purpose?
cedigerAuthor Commented:
Privesh, That is what I needed. Thank you!
All Courses

From novice to tech pro — start learning today.