![]() |
|
#1
|
|||
|
|||
Inheritance IssueI have a CMyListView class that inherits from CListView. Within that class, I handle some user-defined messages such as WM_USER + 100, etc. To handle these, I use ON_MESSAGE( WM_USER + 100, OnUserMessage100 ) in my message map. The signature looks like this: void OnUserMessage( int i ).
This all works fine until I decided that I also need to inherit from another abstract class (interface) that I made that has some virtual methods: CPP / C++ / C Code:
So now, CMyListView class looks like: CPP / C++ / C Code:
When I compile, it no longer likes the ON_MESSAGE() lines saying: "cannot convert from 'void.... to int....'" Does anyone know why it would accept the ON_MESSAGE() before the change but not afterward? Last edited by LuciWiz : 28-Aug-2008 at 05:07.
Reason: Please insert your C++ code between [cpp] & [/cpp] tags
|
|
#2
|
|||
|
|||
Re: Inheritance IssueLooking around i found a quote that stated "Multiple inheritance of CWnd-derived classes is not supported by MFC, period". Does your CVirtualListControl class have any CWnd derived items in it? This discussion also talked about trying to incorporate virtual functions and how it has issues with message handlers. It seems like it could relate to your problem. It sounds like your custom class is having its messages messed up by the virtual functions. Please let use know when/how you resolve this problem.
|
|
#3
|
|||
|
|||
Re: Inheritance IssueProblem solved. I had to simply change the signatures of the functions passed into the ON_MESSAGE() macro. The current signatures look like:
void FunctionName(void); and the compiler is lenient about letting this happen. But, as soon as I inherit from my interface, the compiler becomes mores strict with this and says that the signature must look like: LRESULT FunctionName( WPARAM, LPARAM ); So, I changed them and..... Viola! It compiles and works fine. I believe that when they say that MFC doesn't support multiple inheritance, that they mean inheriting from multiple MFC classes. |
Recent GIDBlog
Python ebook by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Virtual multiple inheritance: constructors order | natasha_u | C++ Forum | 2 | 25-Jul-2007 03:26 |
| Inheritance Suspicious Problem | Peter_APIIT | C++ Forum | 12 | 15-May-2007 23:01 |
| how to issue dos command from c program | jaininaveen | C Programming Language | 2 | 03-Mar-2006 11:02 |
| PHP/MySQL coding issue | cmarti | MySQL / PHP Forum | 3 | 26-Jul-2004 09:01 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The