Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. delegate trouble

delegate trouble

Scheduled Pinned Locked Moved Managed C++/CLI
helpregex
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rob Tomson
    wrote on last edited by
    #1

    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.

    C 1 Reply Last reply
    0
    • R Rob Tomson

      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.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Is void the same as System::Void ? I doubt it. Christian Graus - Microsoft MVP - C++

      R 1 Reply Last reply
      0
      • C Christian Graus

        Is void the same as System::Void ? I doubt it. Christian Graus - Microsoft MVP - C++

        R Offline
        R Offline
        Rob Tomson
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups