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(unmamange d), 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(functi on 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::Unma nagedFunc1()
{
MySpace::Manage d ^man = gcnew MySpace::Manage d;
//I need to pass UnmanagedFunc2( ) here as a delegate/callback as a
//parameter to ManagedFunction .
man->ManagedFunctio n(??)
}
void Unmanaged::Unma nagedFunc2()
{
}
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.