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. C / C++ / MFC
  4. Error while adding ON_BN_CLICKED event.

Error while adding ON_BN_CLICKED event.

Scheduled Pinned Locked Moved C / C++ / MFC
help
4 Posts 3 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.
  • D Offline
    D Offline
    Deepu Antony
    wrote on last edited by
    #1

    Hi I have a class MyClass, which is derived from CWnd and COleDropTarget. class MyClass:public CWnd, public COleDropTarget { }; I am having a button in my class. While adding ON_BN_CLICKED(BUTTON_ID, OnClick) event in the message map entry, i am getting the following compiler error, Error C2594: 'Static cast': ambigious convertion form 'void (__thiscall MyClass::*) (void)' to AFX_PMSG. can anybody tell me what's the issue. Thanks

    T C 2 Replies Last reply
    0
    • D Deepu Antony

      Hi I have a class MyClass, which is derived from CWnd and COleDropTarget. class MyClass:public CWnd, public COleDropTarget { }; I am having a button in my class. While adding ON_BN_CLICKED(BUTTON_ID, OnClick) event in the message map entry, i am getting the following compiler error, Error C2594: 'Static cast': ambigious convertion form 'void (__thiscall MyClass::*) (void)' to AFX_PMSG. can anybody tell me what's the issue. Thanks

      T Offline
      T Offline
      ThatsAlok
      wrote on last edited by
      #2

      Deepu Antony wrote:

      ON_BN_CLICKED(BUTTON_ID, OnClick)

      change it to

      ON_BN_CLICKED(BUTTON_ID, &MyClass::OnClick)

      Also, signature of the function should be like this

      void FunctionName();

      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
      Never mind - my own stupidity is the source of every "problem" - Mixture

      cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You

      D 1 Reply Last reply
      0
      • T ThatsAlok

        Deepu Antony wrote:

        ON_BN_CLICKED(BUTTON_ID, OnClick)

        change it to

        ON_BN_CLICKED(BUTTON_ID, &MyClass::OnClick)

        Also, signature of the function should be like this

        void FunctionName();

        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
        Never mind - my own stupidity is the source of every "problem" - Mixture

        cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You

        D Offline
        D Offline
        Deepu Antony
        wrote on last edited by
        #3

        Hi, Still i am getting the same error. :(

        1 Reply Last reply
        0
        • D Deepu Antony

          Hi I have a class MyClass, which is derived from CWnd and COleDropTarget. class MyClass:public CWnd, public COleDropTarget { }; I am having a button in my class. While adding ON_BN_CLICKED(BUTTON_ID, OnClick) event in the message map entry, i am getting the following compiler error, Error C2594: 'Static cast': ambigious convertion form 'void (__thiscall MyClass::*) (void)' to AFX_PMSG. can anybody tell me what's the issue. Thanks

          C Offline
          C Offline
          Cool_Dev
          wrote on last edited by
          #4

          the ambiguity is both CWnd and COleDropTarget are derived from CCmdTarget. Due to non-virtual inheritance, there will be multipe occurances of AFX_PMSG. Actually why do you inherit a window class from COleDropTarget? Refer COleDropTarget documentation to see its usage.

          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