IntroductionMany applications allow the user to input and edit data using forms. If this is done in an MDI environment, managing the sizes of the MDI frame windows in which the forms are displayed can look like a daunting task. This article shows you how to call MFC functions to size the MDI child frame window to fit the form contained in the form view within it. Resize Your Form With MFC!Look in your derived form view class for a void CMyFormView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit(FALSE);
...
}
The size of the client area of the view's MDI child frame window should now match the size of the dialog template used to place the controls on the form. Don't Resize or Maximize!The sample code provided with this article shows how to resize your form view frame windows to fit their forms,
as outlined above. However, you probably don't want the user to be able to resize or maximize the window thereby
defeating the purpose of calling BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs) { if( !CMDIChildWnd::PreCreateWindow(cs) ) return FALSE; cs.style &= ~(WS_THICKFRAME); cs.style &= ~(WS_MAXIMIZEBOX); cs.style |= WS_BORDER; return TRUE; } ConclusionIf you have any questions about what I've done with these techniques, please feel free to contact me anytime, or post a message in the message board below! |
|