In the namespace block of your control code define delegates for the events like this:
namespace DotNetControl
{
[ComVisible(false)]
public delegate void MyClick1EventHandler();
[ComVisible(false)]
public delegate void MyClick2EventHandler();
...
Define a public interface to expose the events of your UserControl class in Visual FoxPro like this (Notice the Guid, InterfaceType, and DispId attributes - you'll need to generate your own Guid):
[GuidAttribute("F11EC17C-59E1-42D1-AE96-712AB79F20AB")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
public interface ControlEvents
{
[DispIdAttribute(1)]
void MyClick1();
[DispIdAttribute(2)]
void MyClick2();
}
The beginning of your class definition should look something like the following (Notice the Guid, ProgId, ClassInterface and ComSourceInterfaces - generate your own Guid and make sure the parameter sent to typeof is the same as the public interface you created) :
[Guid("2DEFE6F9-6738-454C-BEF1-CF944E7F5F06")]
[ProgId("DotNetControl.DotNetToolbar")]
[ClassInterface(ClassInterfaceType.AutoDual), ComSourceInterfaces(typeof(ControlEvents))]
public partial class DotNetToolbar : UserControl
{
public DotNetToolbar()
{
InitializeComponent();
}
...
Specify your events
event DotNetControl.MyClick1EventHandler MyClick1;
event DotNetControl.MyClick2EventHandler MyClick2;