all groups > dotnet interop > september 2004 >
You're in the

dotnet interop

group:

event fired by C# component not traped in VC.NET(ATL composit cont


event fired by C# component not traped in VC.NET(ATL composit cont satyaprakash
9/28/2004 9:53:02 PM
dotnet interop:
Hi Everybody,
We have C# component. which has been hosted in ATL composit control.
we are trying to caught event fired by C# component in ATL component.
we have implemented sink class derived from IDispEventImpl.
our call to DispEventAdvise method failed with error code - " 0x80040200"
not getting connection point.
Please suggest how event is captured in ATL component.
Regards,
satya

Re: event fired by C# component not traped in VC.NET(ATL composit cont vijai thoppae
9/29/2004 3:43:40 PM
Satya,

Here's an example of how things are defined in C# for ATL to catch the
event.
Define a delegate & a corresponding event. Also an interface containing
equivalent method. Note the event instance name, must be same as the
interface method for AtlAdvise to succeed.
public event DefaultButtonHandler DefaultButton;

// Delegate Definitions...

[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]

public interface IHostMessageSink

{

[DispId(1)] void DefaultButton(int nCtrlIndex);

}

//C# side

public delegate void DefaultButtonHandler(int nCtrlIndex);

[

ComVisible(true),

Guid("1A151E44-FE24-4172-8D5D-FD7A30BA85EB"),

ClassInterface(ClassInterfaceType.None),

ComSourceInterfaces(typeof(IHostMessageSink))

]

public class CWindowHost : System.Windows.Forms.UserControl

{

// Event Definitions..

public event DefaultButtonHandler DefaultButton;

}

Try this out.

Thanks,

VT

[quoted text, click to view]

AddThis Social Bookmark Button