I have an ActiveX control (an OCX file) which raises an event. I want to catch that event in C#. How do I go about doing it?
I can catch the control's event in JavaScript, here is the code for that
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>
<body >
<script type="text/javascript" for="CRMCntrl1" event="NewCall(szCallID, szCallType, nCallStartTime, szCLI, szOtherInfo)">
document.getElementById("abc").innerHTML="CallID: " + szCallID + "</br>" +
"CallType: " + szCallType + "</br>" +
"CallStartTime: " + nCallStartTime + "</br>" +
"CLI: " + szCLI + "</br>" +
"OtherInfo: " + szOtherInfo + "</br>" ;
</script>
<p>
<object id="CRMCntrl1" classid="clsid:D26FE0DF-5CAC-44E4-AA7A-E1794D9634D1">
</object>
</p>
<div id="abc">
</div>
</body>
</html>
I want to do it in C#. So I added a COM reference of the control. It contains interfaces which I implemented in my Form's class. In one of the interface there is an event, I subscribed to that event, basically it is the event which I want to capture, but it isn't raised.
Here is my C# Code
// other namespaces here
using CRMCNTRLLib;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form, CRMCntrl
{
public Form1()
{
InitializeComponent();
this.NewCall += new _DCRMCntrlEvents_NewCallEventHandler(this.OnNewCall);
}
public event _DCRMCntrlEvents_NewCallEventHandler NewCall;
public void AboutBox()
{
MessageBox.Show("steadfast");
}
public void OnNewCall(string szCallID, string szCallType, int nCallStartTime, string szCLI, string szOtherInfo)
{
MessageBox.Show(szCallID + szCallType + nCallStartTime + szCLI + szOtherInfo);
}
}
}