473,387 Members | 2,436 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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*
pVariantArrayRequired);

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

SafeArrayUnaccessData(psaVectorData);

SafeArrayDestroy(psaVectorData);

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;
VariantClear(&vtArrayPositions);
m_ptrControl->GetEmptyVectorDatumVariantArray(m_nNumTestDatum s,
&vtArrayPositions);

SAFEARRAY* psa = vtArrayPositions.parray;

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

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

::SafeArrayUnaccessData(psa);

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++.

QUESTION:
How can I call these two methods from c#?

Mar 13 '06 #1
0 1294

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Alex Vinokur | last post by:
Various forms of argument passing ================================= C/C++ Performance Tests ======================= Using C/C++ Program Perfometer...
15
by: Dave | last post by:
I'm currently working on a small project (admitedly for my CS class) that compares the time difference between passing by value and passing by reference. I'm passing an array of 50000 int's. ...
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
9
by: justanotherguy63 | last post by:
Hi, I am designing an application where to preserve the hierachy and for code substitability, I need to pass an array of derived class object in place of an array of base class object. Since I...
8
by: kalinga1234 | last post by:
there is a problem regarding passing array of characters to another function(without using structures,pointer etc,).can anybody help me to solve the problem.
10
by: Pete | last post by:
Can someone please help, I'm trying to pass an array to a function, do some operation on that array, then return it for further use. The errors I am getting for the following code are, differences...
6
by: DeepaK K C | last post by:
Could anybody tell me how to pass array to a function by value? -Deepak
11
by: John Pass | last post by:
Hi, In the attached example, I do understand that the references are not changed if an array is passed by Val. What I do not understand is the result of line 99 (If one can find this by line...
8
by: S. | last post by:
Hi all, Can someone please help me with this? I have the following struct: typedef struct { char *name; int age; } Student;
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.