In a c# client I have the following:
double [] data = {1.0,2.0,3.0,4.0};
I have an OCX wriiten in c++ using dev studio 6.0.
Can I pass the array to the OCX? How would you do this?
I've looked and looked and failed so far. Is it possible?
Thanks,
Mitch.
yoga weazel - 10 May 2006 15:44 GMT
How are you using the OCX? If you just use the IDE to import the COM control
into .NET it generates the aximp.exe output for you. Once you have the
control instance you can invoke methods on it just like any other object.
For example, say you OCX control is call MyControlLib.MyControl. The wrapper
class would be AxMyControlLib.AxMyControl so when you dropped the OCX control
onto you form in the designer behind the scenes an instance of
AxMyControlLib.AxMyControl would have been instantiated in the codebehind and
added to the form just like any .NET control. You can use this member
instance to call methods of your control.
Now if the method you want to call is not public you will have to either
modify the wrapper class generated by AxImp (you can request C# source code
generated for the wrapper by AxImp.exe at the command line manually) or use
System.Reflection to get the MethodInfo instance you want to call and then
use MethodInfo.Invoke. For example,
Type ctrlType = myControlInstance.GetType();
MethodInfo method = ctrlType.GetMethod("MyMethod", BinderFlags.NonPublic);
method.Invoke(myControlInstance, BindingFlags.InvokeMethod, null, args, null);
where args is an Object[] of the arguments passed to the method being called.
Take a look at System.Reflection namespace and System.Type class for more
info.
Mike
> In a c# client I have the following:
>
[quoted text clipped - 8 lines]
> Thanks,
> Mitch.