Author | Topic: Automation object as Event Parameter | |
---|---|---|
Roger Donnay | Automation object as Event Parameter on Sun, 03 Feb 2008 09:36:29 -0700 I am very close to having a C# program work as an ActiveX control with Xbase++. I have added many types of controls in the C# toolbox and can manipulate them in the Xbase++ program with no problem by calling their properties and methods. I can publish events in the C# program and react to those events in the Xbase++ program (thanks to Till Warweg). When I am completed with this project, I will share the C# and Xbase++ code with everyone and will write a detailed white paper on how to do this. Example of C# code that accomplishes this: [Guid("7BD20046-DF8C-44A6-8F6B-687FAA26FA71"), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)] public interface UserControl1Events { [DispId(4)] void DateChanged( int n, object o, DateRangeEventArgs e, string c1, string c2 ); } public delegate void DateChangedDelegate( int n, object o, DateRangeEventArgs e, string start, string end ); public event DateChangedDelegate DateChanged; private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e) { DateChanged(1, this.monthCalendar1, e, e.Start.ToShortDateString(), e.End.ToShortDateString()); } * ----------------------------- On the Xbase++ side: oControl:DateChanged := {|n,o1,o2,c1,c2|DateChanged(oControl,n,o1,o2,c1,c2)} FUNCTION DateChanged( oControl, n, oCalendar, oDateRangeEventArgs, c1, c2 ) oControl:label1:text := 'You chose ' + c1 RETURN nil * -------------------------------------- What I haven't figured out however, is how to use an Automation Object that has been passed as an argument via the event handler. For Example, I would have expected the below code to work, but it gives an Automation error. If I could figure out how to make this work, then it would simplify the code in the C# program and I could control the reaction to events in the Xbase++ program. Any ideas? FUNCTION DateChanged( oControl, n, oCalendar, oDateRangeEventArgs, c1, c2 ) oControl:label1:text := oDateRangeEventArgs:Start:ToShortDateString() RETURN nil |