Edit

Share via


CFormView Class

The base class used for form views.

Syntax

class CFormView : public CScrollView

Members

Protected Constructors

Name Description
CFormView::CFormView Constructs a CFormView object.

Public Methods

Name Description
CFormView::IsInitDlgCompleted Used for synchronization during initialization.

Remarks

A form view is essentially a view that contains controls. These controls are laid out based on a dialog-template resource. Use CFormView if you want forms in your application. These views support scrolling, as needed, using the CScrollView functionality.

When you're Creating a Forms-Based Application, you can base its view class on CFormView, making it a forms-based application.

You can also insert new Form Topics into document-view-based applications. Even if your application didn't initially support forms, Visual C++ will add this support when you insert a new form.

The MFC Application Wizard and the Add Class command are the preferred methods for creating forms-based applications. If you need to create a forms-based application without using these methods, see Creating a Forms-Based Application.

Inheritance Hierarchy

CObject

CCmdTarget

CWnd

CView

CScrollView

CFormView

Requirements

Header: afxext.h

CFormView::CFormView

Constructs a CFormView object.

CFormView(LPCTSTR lpszTemplateName);
CFormView(UINT nIDTemplate);

Parameters

lpszTemplateName
Contains a NULL-terminated string that is the name of a dialog-template resource.

nIDTemplate
Contains the ID number of a dialog-template resource.

Remarks

When you create an object of a type derived from CFormView, invoke one of the constructors to create the view object and identify the dialog resource on which the view is based. You can identify the resource either by name (pass a string as the argument to the constructor) or by its ID (pass an unsigned integer as the argument).

The form-view window and child controls aren't created until CWnd::Create is called. CWnd::Create is called by the framework as part of the document and view creation process, which is driven by the document template.

Note

Your derived class must supply its own constructor. In the constructor, invoke the constructor, CFormView::CFormView, with the resource name or ID as an argument as shown in the preceding class overview.

Example

// MyFormView.h

// CMyFormView form view

class CMyFormView : public CFormView
{
   DECLARE_DYNCREATE(CMyFormView)

protected:
   CMyFormView(); // protected constructor used by dynamic creation
   virtual ~CMyFormView();

public:
   enum
   {
      IDD = IDD_MYFORMVIEW
   };
#ifdef _DEBUG
   virtual void AssertValid() const;
#ifndef _WIN32_WCE
   virtual void Dump(CDumpContext &dc) const;
#endif
#endif

protected:
   virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support

   DECLARE_MESSAGE_MAP()
public:
   afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
};

 

// MyFormView.cpp

#include "MyFormView.h"

// CMyFormView

IMPLEMENT_DYNCREATE(CMyFormView, CFormView)

CMyFormView::CMyFormView()
    : CFormView(CMyFormView::IDD)
{
}

CFormView::IsInitDlgCompleted

Used by MFC to ensure that initialization is completed before performing other operations.

BOOL IsInitDlgCompleted() const;

Return Value

True if the initialization function for this dialog has completed.

See also

MFC Sample SNAPVW
MFC Sample VIEWEX
CScrollView Class
Hierarchy Chart
CDialog Class