468,140 Members | 1,168 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,140 developers. It's quick & easy.

passing array to OCX

Hi, could anyone help me with the following problem?

I have an ActiveX control developed using Visual Studio 6.0 and it has
a method declared in the .odl file as follows:

void GetEmptyVectorDatumVariantArray(long nNumData, VARIANT*

The body of this method is simply:

SAFEARRAYBOUND sab = {nNumData, 0};

SAFEARRAY* pSaCreated = SafeArrayCreate(VT_R8, 1, &sab);

pVariantArrayRequired->vt = VT_ARRAY | VT_R8;
pVariantArrayRequired->parray = pSaCreated;

So we see that the net result is a method which sets up and returns an
empty safearray.

Now I need to pass a safearray of data to the activex control, so I
have one final method defined in it as foolows in the .odl:

void SetVectorField(VARIANT* vtArrayVectorData, long nNumElements);

the body of this is simply:

SAFEARRAY* psaVectorData = vtArrayVectorData->parray;

double* pRawData = NULL;

SafeArrayAccessData(psaVectorData, (void**)&pRawData);

m_p3DWnd->SetVectorField(pRawData,nNumElements); // Pass data to
another class



So we see that this simply takes a safearray and passes on the data to
another class.

Finally I call the above to methods in c++ as follows:

VARIANT vtArrayPositions;
m_ptrControl->GetEmptyVectorDatumVariantArray(m_nNumTestDatum s,

SAFEARRAY* psa = vtArrayPositions.parray;

double* pVectorDatums = NULL;
SafeArrayAccessData(psa, (void**)&pVectorDatums);

for(int nDatum = 0; nDatum < m_nNumTestDatums; nDatum++)
pVectorDatums[nIndexBase] = 1.0;


m_ptrControl->SetVectorField(&vtArrayPositions,m_nNumTestDatu ms );

So basically I fill the returned empty array with 1's and then pass it
to the activex control.

I all works perfectly - in c++.

How can I call these two methods from c#?

Mar 13 '06 #1
0 1140

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

15 posts views Thread by Dave | last post: by
8 posts views Thread by kalinga1234 | last post: by
6 posts views Thread by DeepaK K C | last post: by
11 posts views Thread by John Pass | last post: by
27 posts views Thread by didacticone | last post: by
1 post views Thread by gcdp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.