Follow the link to the example and read it -- it's pretty simple and well (sort of) explained!
Main Topics
Browse All TopicsI have Native C++ code with a callback function of
typedef void (*InquiryCompleteCallback)
and a variable of
InquiryCompleteCallback inquiryComplete;
Now from managed CLI\C++ code I can access this class by
Native::CSomeClass* someClass= new Native::CSomeClass;
Now how to I manage to get the call back into the manage code
I have been trying things like
someClass->inquiryComplete
but I get the error
error C3374: can't take address of 'ManagedClass::OnInquiryCo
Could anyone please help.
Thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
In unmanaged C++ you can define a static function to use for a call back:
class Unmanaged
{
public:
static void MyCallback(BOOL, short);
...
};
In managed C++ it is the __delegate specifier which makes a 'globally' defined function a valid callback function (see the link evilrix supplied).
In both cases you have the problem to call non-static or non-global functions from within the callback function. You normally do that by using one of the arguments that is passed to callback. If the callback was properly defined you can pass some kind of id when registeruing the callback function. That id was passed as an argument when the callback function was called. You then can retrieve the 'instance' of a class (managed or unmanaged) by using that id, e. g. by calling a static 'retrieve' function where you pass the id.
class Managed
{
static ManagedArray allobjects; // holds all instances of Managed
...
public:
...
static Managed& retrieve(int id)
{
return allobjects.get(id);
}
};
I hope the above code will compile in a managed class (I have no experience with managed code). If not the concept should be valid nevertheless even if managed code requires a different syntax.
Regards, Alex
Thanks for your responses, I had already figured out the concept of callbacks it was the syntax that I couldn't get right, but I eventually figured it out.
someClass->inquiryComplete
and the OnInquiryComplete has to be static
I did a quick writeup of my solution at http://www.dotnetcore.com/
Thanks
Business Accounts
Answer for Membership
by: evilrixPosted on 2007-10-29 at 07:31:14ID: 20169672
It's all explained here... /en-us/lib rary/d186x cf0.aspx
http://msdn2.microsoft.com