GIDForums  

Go Back   GIDForums > Computer Programming Forums > MS Visual C++ / MFC Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 27-Aug-2008, 09:57
fakepoo fakepoo is offline
Regular Member
 
Join Date: Oct 2007
Posts: 534
fakepoo is a jewel in the roughfakepoo is a jewel in the roughfakepoo is a jewel in the rough

Inheritance Issue


I 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:
class CVirutalListControl
{
  public:
    virtual void SetVirtualListCount( long lCount ) = 0;
};

So now, CMyListView class looks like:

CPP / C++ / C Code:
class CMyListView : public CListView, public CVirtualListControl
{
...
};

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  
Old 27-Aug-2008, 22:02
Studly Studly is offline
Junior Member
 
Join Date: Mar 2008
Posts: 31
Studly will become famous soon enough

Re: Inheritance Issue


Looking 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  
Old 28-Aug-2008, 09:59
fakepoo fakepoo is offline
Regular Member
 
Join Date: Oct 2007
Posts: 534
fakepoo is a jewel in the roughfakepoo is a jewel in the roughfakepoo is a jewel in the rough

Re: Inheritance Issue


Problem 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 GIDBlogPython ebook by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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

All times are GMT -6. The time now is 05:35.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.