Click to See Complete Forum and Search --> : Using callback function in c++ .net


testhyc
August 6th, 2004, 07:18 AM
Hello. I have the following problem.

I am try to use c++ .net create a .net class. I want to call a callback function,and let this callback function point
to the __gc class's method,and through this method trigger the class's event

I want use following function
extern long __cdecl sr_enbhdlr(long ddd, unsigned long event_type,long (*hdlr)(unsigned long parm));

aI declare following method in __gc class
long event_handler(unsigned long param)

and I write below code to call this function
sr_enbhdlr(EV_ANYDEV, EV_ANYEVT,event_handler);

When I want compiler these code,the error message recieved is as below:
error C2664: 'sr_enbhdlr' : can't convert 'long (unsigned long)' to 'long (__cdecl *)(unsigned long)' on parameter 3

Where's the problem and how can i fix it?
Can someone help me?
Can someone help me?

tdgiang
December 8th, 2005, 11:27 PM
I have the same problem.
I've tried use __delegate. But it still not work.
If you know how to solve the problem, please let me know
thanks
tdgiang@vnpt.com.vn