WinFormsView Sample: Demonstrates Using .NET Framework Windows Forms Controls as MFC Views

The WinFormsView sample demonstrates how to use a .NET Framework Windows Forms control as a View in an MFC application. The sample demonstrates the following:

  • Hosting a .NET Framework Windows Forms control in MFC using Managed Extensions for C++.
  • Using the Windows Forms control as an MFC View class.
  • Extending the MFC command routing infrastructure to the Windows Forms control.
  • Using .NET Framework custom attributes to specify command handlers and command UI update handlers.

Building and Running the Sample

To build and run WinFormsView using Visual Studio

  1. In the Visual Studio IDE, load the solution file WinFormsView.sln.
  2. On the Build menu, click Build Solution.
  3. On the Debug menu, click Start.


This sample demonstrates the following keywords:

COleControlSite, System::UserControl, System::Runtime::InteropServices::GetIUnknownForObject, CWnd::CreateControl, System::Attribute, System::Reflection::MethodInfo, __try_cast, System::Attribute::GetCustomAttribute, System::Reflection::BindingFlags, CView::OnCmdMsg

See Also

Managed Extensions for C++ Samples