Skip to content

Latest commit

 

History

History
129 lines (100 loc) · 4.21 KB

File metadata and controls

129 lines (100 loc) · 4.21 KB
title CWinFormsView Class | Microsoft Docs
ms.custom
ms.date 11/04/2016
ms.reviewer
ms.suite
ms.technology
cpp-windows
ms.tgt_pltfrm
ms.topic reference
f1_keywords
CWinFormsView
AFXWINFORMS/CWinFormsView
AFXWINFORMS/CWinFormsView::CWinFormsView
AFXWINFORMS/CWinFormsView::GetControl
dev_langs
C++
helpviewer_keywords
MFC [C++], Windows Forms support
CWinFormsView class
Windows Forms [C++], MFC support
ms.assetid d597e397-6529-469b-88f5-7f65a6b9e895
caps.latest.revision 26
author mikeblome
ms.author mblome
manager ghogen
translation.priority.ht
cs-cz
de-de
es-es
fr-fr
it-it
ja-jp
ko-kr
pl-pl
pt-br
ru-ru
tr-tr
zh-cn
zh-tw

CWinFormsView Class

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

Syntax

class CWinFormsView : public CView;  

Members

Public Constructors

Name Description
CWinFormsView::CWinFormsView Constructs a CWinFormsView object.

Public Methods

Name Description
CWinFormsView::GetControl Retrieves a pointer to the Windows Forms control.

Public Operators

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

Remarks

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.

Note

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

Note

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

Requirements

Header: afxwinforms.h

CWinFormsView::CWinFormsView

Constructs a CWinFormsView object.

CWinFormsView(System::Type^ pManagedViewType);  

Parameters

pManagedViewType
A pointer to the data type of the Windows Forms user control.

Example

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.

[!code-cppNVC_MFC_Managed#1]

[!code-cppNVC_MFC_Managed#2]

CWinFormsView::GetControl

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.

Remarks

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

CWinFormsView::operator Control^

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

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

Remarks

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

Example

See CWinFormsView::GetControl.

See Also

Hierarchy Chart
CWinFormsControl Class
CWinFormsDialog Class
CFormView Class