0
votes

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
The formview in the image covers the whole main window's client area. So it is "maximized". If you mean that you want to resize the view and its controls, this is not possible this way, because the size of the controls is determined by your dialog resource. But you can do it programmatically, you have to iterate through the controls and resize them one by one as needed (GetWindow()). The RecalcLayout()/ResizeParentToFit() technique is used to resize the main window so that it fits the form exactly - and of course it has no meaning if the main window is maximized.Constantine Georgiou
@ConstantineGeorgiou I understand what you are talking about... I'll find the way to use GetWindow() . Thank youuser530530

1 Answers

0
votes

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