Hi, I was wondering if anyone ever used an OCX made in .NET in conjunction with Progress 9. I managed to make a simple OCX in C#. Method calls work ok, but I don't seem to be able to implement a COM event sink properly. The events are just ignored by Progress, even though the OCX appears to be valid and Progress COM Object Viewer displays a correct syntax for my event handler. Any ideas/pointers would be greatly appreciated. Thanks.
The sources - Progress side:
The sources - .NET side (C#):
The sources - Progress side:
Code:
DO:
DEF VAR i-test AS INT NO-UNDO.
DEF VAR ch-test AS COM-HANDLE NO-UNDO.
CREATE "ComTest.TestClass" ch-test.
IF VALID-HANDLE(ch-test) THEN DO:
ch-test:ENABLE-EVENTS("TestClass").
/* the TestMethod is called OK, but it should raise an event */
/* well, it doesn't */
i-test = ch-test:TestMethod("blah blah").
MESSAGE i-test.
END.
END.
PROCEDURE TestClass.TestEvent:
MESSAGE "TestEvent".
END PROCEDURE.
The sources - .NET side (C#):
Code:
using System;
using System.ComponentModel;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace ComTest
{
[ComVisible(false)]
public delegate void TestDelegate();
[GuidAttribute("31593BBD-B67E-4fd5-AE26-F0CA73A81B80")]
[ProgId("ComTest.TestClass")]
[ClassInterface(ClassInterfaceType.AutoDual)]
[ComSourceInterfaces("ComTest.TestClassEvents")]
public class TestClass
{
public TestClass()
{
}
public int TestMethod(string Param)
{
if(DialogResult.Yes==MessageBox.Show(Param, "", MessageBoxButtons.YesNo))
{
// this should raise the event
// but TestEvent is always null
if(TestEvent!=null) TestEvent();
}
return 1234;
}
public event TestDelegate TestEvent;
}
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface TestClassEvents
{
void TestEvent();
}
}