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. ON_MESSAGE and multiple inheritance

ON_MESSAGE and multiple inheritance

Scheduled Pinned Locked Moved C / C++ / MFC
hardwareoophelp
5 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.
  • W Offline
    W Offline
    Will Woods
    wrote on last edited by
    #1

    Hi, I have a class

    class CTestDlg : public CDialog , public D360::CController
    {

    which I want to respond to messages like

    BEGIN_MESSAGE_MAP(CTestDlg, CDialog)
    //{{AFX_MSG_MAP(CTestDlg)
    ON_MESSAGE(OLDA_WM_BUFFER_DONE, OnBufferDone)
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()

    This worked when the CTestDlg class only inherited from CDialog, but now I get the following compilation error

    error C2440: 'type cast' : cannot convert from 'int (__thiscall CTestDlg::*)(unsigned int,long)' to 'long (__thiscall CWnd::*)(unsigned int,long)'
    Pointers to members have different representations; cannot cast between them

    I don't know much about the D360::CController class, it was supplied with some hardware. Any suggestions would be appreciated. Will

    T 1 Reply Last reply
    0
    • W Will Woods

      Hi, I have a class

      class CTestDlg : public CDialog , public D360::CController
      {

      which I want to respond to messages like

      BEGIN_MESSAGE_MAP(CTestDlg, CDialog)
      //{{AFX_MSG_MAP(CTestDlg)
      ON_MESSAGE(OLDA_WM_BUFFER_DONE, OnBufferDone)
      //}}AFX_MSG_MAP
      END_MESSAGE_MAP()

      This worked when the CTestDlg class only inherited from CDialog, but now I get the following compilation error

      error C2440: 'type cast' : cannot convert from 'int (__thiscall CTestDlg::*)(unsigned int,long)' to 'long (__thiscall CWnd::*)(unsigned int,long)'
      Pointers to members have different representations; cannot cast between them

      I don't know much about the D360::CController class, it was supplied with some hardware. Any suggestions would be appreciated. Will

      T Offline
      T Offline
      Tomasz Sowinski
      wrote on last edited by
      #2

      Do you really have to derive from D360::CController? Are there any CController virtual functions you are overriding? Tomasz Sowinski -- http://www.shooltz.com

      What is "scratch" and why can everything be made from it?

      W 1 Reply Last reply
      0
      • T Tomasz Sowinski

        Do you really have to derive from D360::CController? Are there any CController virtual functions you are overriding? Tomasz Sowinski -- http://www.shooltz.com

        What is "scratch" and why can everything be made from it?

        W Offline
        W Offline
        Will Woods
        wrote on last edited by
        #3

        As far as I can tell, yes I do have to derive from D360::CController - it is doing something I don't understand with ATL to interface with the hardware. The only example code the company sent me used multiple inheritance. Is this a general problem with ON_MESSAGE and multiple inheritance, or just a strange quirk of the classes I am trying to inherit from? Will

        T 1 Reply Last reply
        0
        • W Will Woods

          As far as I can tell, yes I do have to derive from D360::CController - it is doing something I don't understand with ATL to interface with the hardware. The only example code the company sent me used multiple inheritance. Is this a general problem with ON_MESSAGE and multiple inheritance, or just a strange quirk of the classes I am trying to inherit from? Will

          T Offline
          T Offline
          Tomasz Sowinski
          wrote on last edited by
          #4

          Will Woods wrote: Is this a general problem with ON_MESSAGE and multiple inheritance, or just a strange quirk of the classes I am trying to inherit from? Well, the MFC wasn't designed with multiple inheritance in mind. This means that you can't have your object derived from CCoolWnd and COtherWnd. OTOH, you can derive your object from CWnd (or CView, CDialog, or any other MFC window class) and non-MFC class[es]. In such case you just have to make sure that MFC class is first in the base classes list. I've used this approach in many MFC-based projects. So one possible reason for your problems would be CController deriving from some MFC class. Can you have a look on the D360 docs? Tomasz Sowinski -- http://www.shooltz.com

          What is "scratch" and why can everything be made from it?

          W 1 Reply Last reply
          0
          • T Tomasz Sowinski

            Will Woods wrote: Is this a general problem with ON_MESSAGE and multiple inheritance, or just a strange quirk of the classes I am trying to inherit from? Well, the MFC wasn't designed with multiple inheritance in mind. This means that you can't have your object derived from CCoolWnd and COtherWnd. OTOH, you can derive your object from CWnd (or CView, CDialog, or any other MFC window class) and non-MFC class[es]. In such case you just have to make sure that MFC class is first in the base classes list. I've used this approach in many MFC-based projects. So one possible reason for your problems would be CController deriving from some MFC class. Can you have a look on the D360 docs? Tomasz Sowinski -- http://www.shooltz.com

            What is "scratch" and why can everything be made from it?

            W Offline
            W Offline
            Will Woods
            wrote on last edited by
            #5

            Problem solved - I had declared the callback functions to return bool (as 'required' by some other hardware drivers) - changing the return type to LRESULT fixed the problem. I wonder why this compiled ok (I just checked it, it does) before I added the second inheritance?? Thanks for your help. Will

            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