G
Guest
Hi,
I have my main application class(unmanaged) that has a none static member
function that I need to pass as a delegate to managed C# method.
In one of the methods of this class(unmamanged), I am calling a managed C#
method(I use gcnew to instantiate the managed class). One of the parameters
of this C# method is a delegate. I need to pass the none static member
function as a delegate(function pointer) as a parameter in the managed C#
function call.
e.g.
//Managed C#
namespace MySpace
{
public delegate int MyDelegate();
MyDelegate rDelegate;
public class Managed
{
void ManagedFunction(MyDelegate del)
{
//do stuff
}
}
}
//Unmanaged C++ written in VC++ 6.0
//.h
class Unmanaged
{
public:
Unmanaged();
~Unmanaged();
void UnmanagedFunc1();
void UnmanagedFunc2();
}
*.cpp
using namespace MySpace;
void Unmanaged::UnmanagedFunc1()
{
MySpace::Managed ^man = gcnew MySpace::Managed;
//I need to pass UnmanagedFunc2() here as a delegate/callback as a
//parameter to ManagedFunction.
man->ManagedFunction(??)
}
void Unmanaged::UnmanagedFunc2()
{
}
Will appreciate all the help I can get on this.
Also what if I need to pass a string also as a parameter to
ManagedFunction(). In unmanaged it is a char* or a CString. How can I do the
conversion to pass it to managed.
Thanks for the help.
I have my main application class(unmanaged) that has a none static member
function that I need to pass as a delegate to managed C# method.
In one of the methods of this class(unmamanged), I am calling a managed C#
method(I use gcnew to instantiate the managed class). One of the parameters
of this C# method is a delegate. I need to pass the none static member
function as a delegate(function pointer) as a parameter in the managed C#
function call.
e.g.
//Managed C#
namespace MySpace
{
public delegate int MyDelegate();
MyDelegate rDelegate;
public class Managed
{
void ManagedFunction(MyDelegate del)
{
//do stuff
}
}
}
//Unmanaged C++ written in VC++ 6.0
//.h
class Unmanaged
{
public:
Unmanaged();
~Unmanaged();
void UnmanagedFunc1();
void UnmanagedFunc2();
}
*.cpp
using namespace MySpace;
void Unmanaged::UnmanagedFunc1()
{
MySpace::Managed ^man = gcnew MySpace::Managed;
//I need to pass UnmanagedFunc2() here as a delegate/callback as a
//parameter to ManagedFunction.
man->ManagedFunction(??)
}
void Unmanaged::UnmanagedFunc2()
{
}
Will appreciate all the help I can get on this.
Also what if I need to pass a string also as a parameter to
ManagedFunction(). In unmanaged it is a char* or a CString. How can I do the
conversion to pass it to managed.
Thanks for the help.