To use WinForms classes from an add-in you need to add a reference to
System.Windows.Forms.dll
to your project.
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.