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 are not 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.

备注

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)
{

}

Requirements

Header: afxext.h

See Also

Reference

CFormView Class

Hierarchy Chart

CWnd::Create

Other Resources

CFormView Members