delegate trouble
-
I can't get my delegate/event to work. It keeps giving me a compiler error of 'the specified function does not match the delegate type'. This is what I have: ...
public delegate void MessageReceivedEventHandler(MessageDetails^ Message);
...ref class CodeProject { public: event MessageReceivedEventHandler^ MessageReceived;
... ...CodeProject^ m_codeProject; m_codeProject->MessageReceived += gcnew MessageReceivedEventHandler(&NS::MessageReceived_Message);
...private: System::Void MessageReceived_Message(MessageDetails^ Message);
It seems that everything is fine but it won't compile. Please help. Thanks, Rob Tomson -- There are 10 kinds of people. Those who understand binary and those who don't. -
I can't get my delegate/event to work. It keeps giving me a compiler error of 'the specified function does not match the delegate type'. This is what I have: ...
public delegate void MessageReceivedEventHandler(MessageDetails^ Message);
...ref class CodeProject { public: event MessageReceivedEventHandler^ MessageReceived;
... ...CodeProject^ m_codeProject; m_codeProject->MessageReceived += gcnew MessageReceivedEventHandler(&NS::MessageReceived_Message);
...private: System::Void MessageReceived_Message(MessageDetails^ Message);
It seems that everything is fine but it won't compile. Please help. Thanks, Rob Tomson -- There are 10 kinds of people. Those who understand binary and those who don't.Is void the same as System::Void ? I doubt it. Christian Graus - Microsoft MVP - C++
-
Is void the same as System::Void ? I doubt it. Christian Graus - Microsoft MVP - C++
actually it is the same when it comes to managed but I found the answer. It turns out that when I add a new event I have to pass in the class that's calling the event: ...
m_codeProject->MessageReceived += gcnew MessageReceivedEventHandler(this, &NS::MessageReceived_Message);
... thanks! Rob Tomson -- There are 10 kinds of people. Those who understand binary and those who don't.