共用方式為


CCtrlView Class

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at CCtrlView Class.

Adapts the document-view architecture to the common controls supported by Windows 98 and Windows NT versions 3.51 and later.

Syntax

class CCtrlView : public CView  

Members

Public Constructors

Name Description
CCtrlView::CCtrlView Constructs a CCtrlView object.

Protected Methods

Name Description
CCtrlView::OnDraw Called by the framework to draw using the specified device context.
CCtrlView::PreCreateWindow Called before the creation of the Windows window attached to this CCtrlView object.

Protected Data Members

Name Description
CCtrlView::m_dwDefaultStyle Contains the default style for the view class.
CCtrlView::m_strClass Contains the Windows class name for the view class.

Remarks

The class CCtrlView and its derivatives, CEditView, CListView, CTreeView, and CRichEditView, adapt the document-view architecture to the new common controls supported by Windows 95/98 and Windows NT versions 3.51 and later. For more information on the document-view architecture, see Document/View Architecture.

Inheritance Hierarchy

CObject

CCmdTarget

CWnd

CView

CCtrlView

Requirements

Header: afxwin.h

CCtrlView::CCtrlView

Constructs a CCtrlView object.

CCtrlView(
    LPCTSTR lpszClass,  
    DWORD dwStyle);

Parameters

lpszClass
Windows class name of the view class.

dwStyle
Style of the view class.

Remarks

The framework calls the constructor when a new frame window is created or a window is split. Override CView::OnInitialUpdate to initialize the view after the document is attached. Call CWnd::Create or CWnd::CreateEx to create the Windows object.

CCtrlView::m_strClass

Contains the Windows class name for the view class.

CString m_strClass;  

CCtrlView::m_dwDefaultStyle

Contains the default style for the view class.

DWORD m_dwDefaultStyle;  

Remarks

This style is applied when a window is created.

CCtrlView::OnDraw

Called by the framework to draw the contents of the CCtrlView object using the specified device context.

virtual void OnDraw(CDC* pDC);

Parameters

pDC
A pointer to the device context in which the drawing occurs.

Remarks

OnDraw is typically called for screen display, passing a screen device context specified by pDC.

CCtrlView::PreCreateWindow

Called before the creation of the Windows window attached to this CWnd object.

virtual BOOL PreCreateWindow(CREATESTRUCT& cs);

Parameters

cs
A CREATESTRUCT structure.

Return Value

Nonzero if the window creation should continue; 0 to indicate creation failure.

Remarks

Never call this function directly.

The default implementation of this function checks for a NULL window class name and substitutes an appropriate default. Override this member function to modify the CREATESTRUCT structure before the window is created.

Each class derived from CCtrlView adds its own functionality to its override of PreCreateWindow. By design, these derivations of PreCreateWindow are not documented. To determine the styles appropriate to each class and the interdependencies between the styles, you can examine the MFC source code for your application's base class. If you choose to override PreCreateWindow, you can determine whether the styles used in your application's base class provide the functionality you need by using information gathered from the MFC source code.

For more information on changing window styles, see the Changing the Styles of a Window Created by MFC.

See Also

CView Class
Hierarchy Chart
CTreeView Class
CListView Class
CRichEditView Class