ON_MESSAGE and multiple inheritance
-
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 themI don't know much about the D360::CController class, it was supplied with some hardware. Any suggestions would be appreciated. Will
-
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 themI don't know much about the D360::CController class, it was supplied with some hardware. Any suggestions would be appreciated. Will
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?
-
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?
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
-
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
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?
-
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?
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