This documentation is archived and is not being maintained.

Adding Managed Extensions for C++ Windows Forms to Your Project

Visual Studio .NET 2003

In Visual C++, you can easily add Windows Forms written with Managed Extensions for C++ to your projects. Managed Extensions for C++ Windows Forms are __gc classes that inherit from the Form class.

Note   You cannot add Windows Forms written with Managed Extensions to native projects. If you want to do mixed-mode programming, then create a Managed Extensions for C++ application and use attributed code to specify the native or managed code blocks.

To add a Windows Form to your project

  1. In Solution Explorer, right-click your project.
  2. On the shortcut menu, click Add, and then click Add New Item.

    The Add New Item dialog box appears.

  3. In the Templates pane, select the Windows Forms Application (.NET) icon.
  4. In the Name field, type the name of your new form (for example Form2), and then click OK.

    New source files, such as Form2.h and Form2.cpp, are generated, and the Windows Forms Designer opens in the integrated development environment (IDE).

If you want your form to inherit from a class that is different from the Form class, then specify this in the class declaration and add appropriate references. For example:

#include "Form1.h"
public __gc class Form2 : public Form1
{
};
Note   When inheriting a form, always put the base class in a separate DLL.

For more information, see Windows Forms Inheritance.

See Also

Managed Extensions for C++ Windows Applications

Show: