I have an existing MFC c++ ocx control that I need to work with a c# class.
If I use a locally defined data structure, everything works. For example,
in my C++ app I declare.
MyCSharpClass DataStructure;
To use the data structure in my c# class I use
DataAccess::Select(%DataStructure);
This works great.
However, when I retreive my DataStructure from the MFC C++ ocx control, I
can not pass the structure to the c# class, I get compile errors. For example
char* pDataStructure;
//ocx call returns a pointer to the data structure
myControl.GetData(pDataSturcture);
Now I need pass (by reference) the data structure to a c# class.
I have tried:
DataAccess::Select(pDataStructure);
as well as other variations to cast the data structure to the c# class.
The data structures in the C++ ocx and the c# class are identical. The data
is allocated on the heap.
How can I pass the pointer returned from my control to the c# class.
Thanks for any assistance. 3 1871
I think that C# is not ready for primetime.. VB is the worlds most
popular langauge
I've never had this problem in VB
Hope that helps
-Todos
On Apr 9, 2:16 pm, j...@nospam.com
<jamesnospam...@discussions.microsoft.comwrote:
I have an existing MFC c++ ocx control that I need to work with a c# class.
If I use a locally defined data structure, everything works. For example,
in my C++ app I declare.
MyCSharpClass DataStructure;
To use the data structure in my c# class I use
DataAccess::Select(%DataStructure);
This works great.
However, when I retreive my DataStructure from the MFC C++ ocx control, I
can not pass the structure to the c# class, I get compile errors. For example
char* pDataStructure;
//ocx call returns a pointer to the data structure
myControl.GetData(pDataSturcture);
Now I need pass (by reference) the data structure to a c# class.
I have tried:
DataAccess::Select(pDataStructure);
as well as other variations to cast the data structure to the c# class.
The data structures in the C++ ocx and the c# class are identical. The data
is allocated on the heap.
How can I pass the pointer returned from my control to the c# class.
Thanks for any assistance.
Since your C++ class is exposed through COM, your best bet is to expose
your data structure through COM as well and then pass that around.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"ja***@nospam.com" <ja************@discussions.microsoft.comwrote in
message news:69**********************************@microsof t.com...
>I have an existing MFC c++ ocx control that I need to work with a c# class.
If I use a locally defined data structure, everything works. For example,
in my C++ app I declare.
MyCSharpClass DataStructure;
To use the data structure in my c# class I use
DataAccess::Select(%DataStructure);
This works great.
However, when I retreive my DataStructure from the MFC C++ ocx control, I
can not pass the structure to the c# class, I get compile errors. For
example
char* pDataStructure;
//ocx call returns a pointer to the data structure
myControl.GetData(pDataSturcture);
Now I need pass (by reference) the data structure to a c# class.
I have tried:
DataAccess::Select(pDataStructure);
as well as other variations to cast the data structure to the c# class.
The data structures in the C++ ocx and the c# class are identical. The
data
is allocated on the heap.
How can I pass the pointer returned from my control to the c# class.
Thanks for any assistance.
"ja***@nospam.com" <ja************@discussions.microsoft.comwrote in message
news:69**********************************@microsof t.com...
>I have an existing MFC c++ ocx control that I need to work with a c# class.
If I use a locally defined data structure, everything works. For example,
in my C++ app I declare.
MyCSharpClass DataStructure;
To use the data structure in my c# class I use
DataAccess::Select(%DataStructure);
This works great.
However, when I retreive my DataStructure from the MFC C++ ocx control, I
can not pass the structure to the c# class, I get compile errors. For example
char* pDataStructure;
//ocx call returns a pointer to the data structure
myControl.GetData(pDataSturcture);
Now I need pass (by reference) the data structure to a c# class.
I have tried:
DataAccess::Select(pDataStructure);
as well as other variations to cast the data structure to the c# class.
The data structures in the C++ ocx and the c# class are identical. The data
is allocated on the heap.
How can I pass the pointer returned from my control to the c# class.
Thanks for any assistance.
How did you declare the Select method? Please no pseudo code.
Willy.
>
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Vinodh Kumar |
last post by:
I see that casting changes the value of a pointer in case of multiple
inheritance.In single inheritance also it is the same know?Isn't it?
Vinodh Kumar P
|
by: Jacob Jensen |
last post by:
This question has probably been asked a million time, but here it comes
again. I want to learn the difference between the three type cast operators:
static_cast, reinterpret_cast, dynamic_cast. A...
|
by: Ingo Nolden |
last post by:
Hi there,
I am writing a smart pointer that is similar to the boost intrusive ptr.
I am trying to make it behave like a c++ pointer including the implicit
and explicit casting behaviour.
Below...
|
by: He Shiming |
last post by:
Hi,
I'm having a little bit of trouble regarding pointer casting in my program.
I don't understand why the following two cases produce different results.
Case 1:
IInterface *pInterface = new...
|
by: Agoston Bejo |
last post by:
What happens exactly when I do the following:
struct A {
int i;
string j;
A() {}
};
void f(A& a) {
cout << a.i << endl;
|
by: Yin99 |
last post by:
I have the following code (Mammal base class, Dog inherits from
Mammal):
Dog *spot= new Dog;
spot->Speak();
Mammal *fido = dynamic_cast<Mammal*>(spot);
fido->Speak();
Dog *bandit =...
|
by: brekehan |
last post by:
I've always been a little sketchy on the differences between static,
dynamic, and reinterpret casting. I am looking to clean up the
following block by using C++ casting instead of the C style...
|
by: Jess |
last post by:
Hello,
It seems both static_cast and dynamic_cast can cast a base class
pointer/reference to a derived class pointer/reference. If so, is
there any difference between them?
In addition, if I...
|
by: Taras_96 |
last post by:
Hi everyone,
I was experimenting with static_cast and reinterpret cast
#include <iostream>
struct A1 { int a; };
struct A2 { double d; };
struct B : public A1, A2
|
by: Wally Barnes |
last post by:
Can someone help a poor C++ programmer that learned the language before
there was a standard lib .. etc ?
Basically I have two classes that look something like below:
template <class T>...
|
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$) {
}
...
|
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...
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |