How can i auto resize MFC SDI formview?

349 views Asked by At

I'm making a MFC SDI project.
There is a main view which i want to maximize, but I don't know how to do it.
(I succeeded to maximized main frame window, but failed to maximized the formview like below image.)
[enter image description here][2]

BOOL CProjectNameApp::InitInstance()
{
...
    m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);
    m_pMainWnd->UpdateWindow();

    return TRUE;
}

void CProjectNameView::OnInitialUpdate()
{
    CFormView::OnInitialUpdate();
    
    //GetParentFrame()->RecalcLayout(TRUE);
    //ResizeParentToFit(FALSE);
}

These are the final things that i did so far.
I wrote m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED); to maximized main window,
and annotation two lines (GetParentFrame()->RecalcLayout(TRUE); and ResizeParentToFit(FALSE);) to the formview to fit the main frame.

I already searched on google and stackoverflow and read many answers but nothing helps me.. How can i solve this problem?
(+) The base class of mainview(ProjectNameView) is CFormview, not CView. And sorry for my poor english.
[2]: https://i.stack.imgur.com/dFMEY.png

1

There are 1 answers

0
Tom Tom On

To auto resize the controls inside the SDI formview, you don't have to write any line of code in VS2019. The rc Editor has the dynamic layout function capabilities.

Here a visualized example how to use it:

enter image description here

The result

enter image description here