Provides the basic functionality for hosting of a Windows Forms control.
template<class TManagedControl> class CWinFormsControl : public CWnd
A .NET Framework Windows Forms control to be displayed in the MFC application.
|CWinFormsControl::CWinFormsControl||Constructs an MFC Windows Forms control wrapper object.|
|CWinFormsControl::CreateManagedControl||Creates a Windows Forms control in an MFC container.|
|CWinFormsControl::GetControl||Retrieves a pointer to the Windows Forms control.|
|CWinFormsControl::GetControlHandle||Retrieves a handle to the Windows Forms control.|
|CWinFormsControl::operator ->||Replaces CWinFormsControl::GetControl in expressions.|
|CWinFormsControl::operator TManagedControl^||Casts a type as a pointer to a Windows Forms control.|
CWinFormsControl class provides the basic functionality for hosting of a Windows Forms control.
For more information on using Windows Forms, see Using a Windows Form User Control in MFC.
Your MFC code should not cache Window handles (usually stored in
m_hWnd). Some Windows Forms control properties require that the underlying Win32
Window be destroyed and recreated using
CreateWindow. The MFC Windows Forms implementation handles the
Create events of the controls to update the
MFC Windows Forms integration works only in projects which link dynamically with MFC (in which AFXDLL is defined).
Creates a Windows Forms control in an MFC container.
inline BOOL CreateManagedControl( System::Type^ pType, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, int nID) inline BOOL CreateManagedControl( DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, int nID); inline BOOL CreateManagedControl( DWORD dwStyle, int nPlaceHolderID, CWnd* pParentWnd); inline BOOL CreateManagedControl( typename TManagedControl^ pControl, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, int nID);
The data type of the control to be created. Must be a Type data type.
The window style to apply to the control. Specify a combination of Window Styles. Currently, only the following styles are supported: WS_TABSTOP, WS_VISIBLE, WS_DISABLED and WS_GROUP.
A RECT Structure that defines the coordinates of the upper-left and lower-right corners of the control (first overload only).
The handle of the static place holder control placed in the Resource Editor. The newly created Windows Forms control replaces the static control, assuming its position, z-order, and styles (second overload only).
A pointer to the parent window.
The resource ID number to be assigned to the newly created control.
An instance of a Windows Forms control to be associated with the CWinFormsControl object (fourth overload only).
If successful, returns a nonzero value. If unsuccessful, returns zero.
This method instantiates a .NET Framework Windows Forms control in an MFC container.
The first overload of the method accepts a .NET Framework data type pType so that MFC can instantiate a new object of this type. pType must be a Type data type.
The second overload of the method creates a Windows Forms control based on the
TManagedControl template parameter of the
CWinFormsControl class. The size and position of the control is based on the
RECT structure passed to the method. Only dwStyle matters for the styles.
The third overload of the method creates a Windows Forms control that replaces a static control, destroying it and assuming its position, z-order, and styles. The static control serves only as a placeholder for the Windows Forms control. When creating the control, this overload combines the styles from dwStyle with the static control's resource styles.
The fourth overload of the method allows you to pass in an already instantiated Windows Forms control pControl that MFC will wrap. It must be of the same type as the
TManagedControl template parameter of the
See Using a Windows Form User Control in MFC for samples on using Windows Form controls.
Constructs an MFC Windows Forms control wrapper object.
The Windows Forms control is instantiated when you call CWinFormsControl::CreateManagedControl.
Retrieves a pointer to the Windows Forms control.
inline TManagedControl^ GetControl() const;
Returns a pointer to the Windows Forms control.
Retrieves a handle to the Windows Forms control.
inline HWND GetControlHandle() const;
Returns a handle to the Windows Forms control.
Replaces CWinFormsControl::GetControl in expressions.
inline TManagedControl^ operator->() const;
This operator provides a convenient syntax that replaces
GetControl in expressions.
For more information on Windows Forms, see Using a Windows Form User Control in MFC.
Casts a type as a pointer to a Windows Forms control.
inline operator TManagedControl^() const;
This operator passes
CWinFormsControl<TManagedControl> to functions that accept a pointer to a Windows Forms control.