Article ID: 897863 - View products that this article applies to.
This article contains information about the supportability of using Microsoft .NET Windows Forms (Winforms) controls in an unmanaged application. These unmanaged applications may include Microsoft Visual Basic 6.0 applications, Microsoft Foundation Classes (MFC) applications, or Microsoft Internet Explorer.
Scenario 1: Host Winforms components as ActiveX controlsIn the Microsoft .NET Framework 1.0, Winforms only supports using Winforms controls in the following:
In the Microsoft .NET Framework 1.1, support has been extended to include MFC 7.x and later versions and any container that is fully compatible with the MFC 7.x ActiveX control container. However, Winforms controls that are registered as ActiveX controls are still not supported. Winforms controls that are created by using the CoCreateInstance function are also not supported. Winforms only supports the managed activation of Winforms controls. When the Winforms controls are created, the controls can be hosted in MFC like other ActiveX controls.
To use Winforms controls in your application, you have to either host the common language runtime by using the unmanaged CLR hosting APIs or use the Managed Extensions for C++ to implement your application. We recommend that you use Managed Extensions for C++.
Scenario 2: Display a Winforms form from an unmanaged applicationIn the .NET Framework, you can display a Winforms form from an unmanaged application, such as a Visual Basic 6.0 application or an MFC 6.0 application. This scenario is supported. You can create a class library in Winforms that includes a method to display the form, and then build the class library for COM Interop. After you create and build the class library, you can use the Interop .dll file from Visual Basic 6.0 or from MFC, and then call the method to display the form. The key is to create a Winforms message pump in the Winforms form. The Winforms form can then run on the message pump.
You can start a Winforms message pump using one of the following methods:
Note Subclassing or setting a form's parent to be a Win32 parent is not supported in any circumstance.
Article ID: 897863 - Last Review: August 26, 2005 - Revision: 1.1
Contact us for more help