The information in this article applies to:
SUMMARY
The CFormView class provides a convenient method to place controls
into a view that is based on a dialog box template. The general
procedure to use a CFormView is described in the documentation for the
class and is illustrated in the VIEWEX and CHKBOOK sample applications
provided with Microsoft Foundation Classes (MFC) versions 2.x and above.
However, these applications do not demonstrate making the initial size
of the frame window to be the same as the initial size of the form.
MORE INFORMATION
The following steps describe how to create an AppWizard generated
application using the CFormView as the default view.
Changing the Size of an SDI Main Frame Around a CFormViewTo change the size of the main frame of an SDI application (that uses CFormView as its view class) to be the appropriate size for the form you designed in App Studio, override the OnInitialUpdate() function in your class derived from CFormView, as follows:
The ResizeParentToFit() function does not prevent the form from
changing size when the user changes the size of the application main
frame (scroll bars are added automatically if needed). To modify the
style of the frame window that is the parent of a form view, you can
override the PreCreateWindow() function in the CMainFrame class
generated by AppWizard. For example, to remove the WS_THICKFRAME style
and prevent the user from changing the size of the window, declare
PreCreateWindow() in MAINFRM.H and add the following code to
MAINFRM.CPP:
Changing the Size of an MDI Child Frame Around a CFormViewThe process of changing the size of an MDI child frame is similar to changing the size of a main frame for an SDI application, as explained above. However, the RecalcLayout() call is not required.To change the size of an MDI child frame around a form view, override the OnInitialUpdate() function in your class derived from CFormView as follows:
If the application overrides the default argument to the
ResizeParentToFit() function, essentially the same consequences occur
as for an SDI application, as explained above. In addition, the child
window may be too large for the enclosing MDI main frame or for the
entire screen.
To change the style of the MDI child frame (for example, to remove the WS_THICKFRAME style so the user cannot change the size of the window), derive an MDI child window class and override the PreCreateWindow function as demonstrated in the SDI example above. Closing an MDI Form with a ButtonTo create a button on a form that closes the document, use ClassWizard to add a message handler for the BN_CLICKED message to the CFormView class. Make sure that the buttons in CFormView do not have the default IDOK or IDCANCEL identifiers. If they do, ClassWizard creates incorrect entries in the message map and incorrect functions for the buttons.Once the message handler is in place, you can simulate the Close command on the File menu with the following code:
This method to close a form prompts the user to save the file if the
IsModified() member function associated with the document returns
TRUE.
Additional query words: kbfasttips
Keywords : kbDocView kbMDI kbMFC KbUIDesign kbVC100 kbVC150 kbVC200 kbVC400 kbVC500 kbVC600 kbGrpMFCATL |
Last Reviewed: November 25, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |