To use WinForms classes from an add-in you need to add a reference to
System.Windows.Forms.dll
to your project.
Note that on Visual Studio 2015 and 2017, where there is no "Common Properties/References" node in the Project Properties, you should instead use the Solution Explorer window: select the "References" node under the project node, and right-click it, then select the "Add Reference..." command.
You may find it convenient to also add the following line to your main source file, which will save quite a bit of typing.
using namespace System::Windows::Forms;
To get access to a class that links XLL+ to the .NET Winforms classes, you should also add the following line to your main source file:
#include <xlpclrforms.h>
The ExcelForm managed class acts as a link between Excel and WinForms (by implementing the interface IWin32Window). Create an ExcelForm object, and it will allow the Excel application window to act as the owner of a WinForms form.
// Call a WinForms method, using a new instance of // the ExcelForm to create an IWin32Window interface // for the main Excel application window. MessageBox::Show( gcnew XllPlus::Forms::ExcelForm(), "Hello from .NET", ".NET message box", MessageBoxButtons::OK, MessageBoxIcon::Hand);
See the ClrDemo sample for an example of the use of ExcelForm.