Is this possible?

  • Thread starter Thread starter mitch
  • Start date Start date
M

mitch

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.
 
Mitch,

Yes, you can, assuming that the method on the object from the OCX is
expecting a SAFEARRAY of doubles.

Have you imported the OCX into .NET? You can easily do this by adding
it to your toolbox (there is a COM tab when you configure the toolbox).

Hope this helps.
 
Hello,

Thanks for your reply.

You sound condifent - like someone whose done it before? I can't.

I have successfully imported the OCX into the toolbox and have a copy
on a form.

In the .odl file I declare:

[id(3)] void UseArray([in]SAFEARRAY(double) pArray);

In the ActiveX ctl's header I declare:

afx_msg void UseArray(SAFEARRAY* pArray);

and in the ctl's dispatch map I have:

DISP_FUNCTION(CTestOCXCtrl, "UseArray", UseArray, VT_EMPTY, VTS_R8)

Is this correct? It all compiles.

In c# I have:

double [] data = {1.0,2.0,3.0,4.0};
axTestOCX1.UseArray(pArray);

And I get and Interop COMException of type mismatch.

It should be so simple. Where am I going so wrong?

Mitch.
 
Typo: Should read:

In c# I have:

System.Array pArray = new double[10];
axTestOCX1.UseArray(pArray);

And I get and Interop COMException of type mismatch.

It should be so simple. Where am I going so wrong?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top