The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

CWinFormsView Class


The new home for Visual Studio documentation is Visual Studio 2017 Documentation on

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

Provides generic functionality for hosting of a Windows Forms control as an MFC view.

class CWinFormsView : public CView;  

Public Constructors

CWinFormsView::CWinFormsViewConstructs a CWinFormsView object.

Public Methods

CWinFormsView::GetControlRetrieves a pointer to the Windows Forms control.

Public Operators

CWinFormsView::operator Control^Casts a type as a pointer to a Windows Forms control.

MFC uses the CWinFormsView class to host a .NET Framework Windows Forms control within an MFC view. The control is a child of the native view and occupies the entire client area of the MFC view. The result is similar to a CFormView view, allowing you to take advantage of the Windows Forms designer and run time to create rich form-based views.

For more information on using Windows Forms, see Using a Windows Form User Control in MFC.

System_CAPS_ICON_note.jpg Note

MFC Windows Forms integration works only in projects which link dynamically with MFC (projects in which AFXDLL is defined).

System_CAPS_ICON_note.jpg Note

CWinFormsView does not support the MFC splitter window ( CSplitterWnd Class). Currently only the Windows Forms Splitter control ( Splitter) is supported.

Header: afxwinforms.h

Constructs a CWinFormsView object.

CWinFormsView(System::Type^ pManagedViewType);  


A pointer to the data type of the Windows Forms user control. For more information, see System.Type.


In the following example, the CUserView class inherits from CWinFormsView and passes the type of UserControl1 to the CWinFormsView constructor. UserControl1 is a custom-built control in ControlLibrary1.dll.

class CMyView : public CWinFormsView



   : CWinFormsView(ControlLibrary1::UserControl1::typeid)

Retrieves a pointer to the Windows Forms control.

System::Windows::Forms::Control^ GetControl() const;  

Return Value

A pointer to a System.Windows.Forms.Control object.


For an example of how to use Windows Forms, see Using a Windows Form User Control in MFC.

Casts a type as a pointer to a Windows Forms control.

operator System::Windows::Forms::Control^() const;  


This operator allows you to pass a CWinFormsView view to functions that accept a pointer to a Windows Forms control of type System.Windows.Forms.Control.


See CWinFormsView::GetControl.

Hierarchy Chart
CWinFormsControl Class
CWinFormsDialog Class
CFormView Class