none
Is it possible to create a message map for a class not directly derived from CWnd or CFrameWnd ? RRS feed

  • Question

  • Hi All,

    Is it possible to create a message map for a class not directly derived from CWnd or CFrameWnd ?
    (It's parent is derived from CWnd though)..

    When I tried to Create the message map in usual manner for a registered message using the following code, I get a type casting error:

    // pseudo code
    public class Parent : public CWnd
    {
    DECLARE_MESSAGE_MAP()
    };

    public class Child: public parent
    {
    DECLARE_MESSAGE_MAP()
    afx_msg long MyHandler(LPARAM lp,WPARAM wp);
    };

    // inside the implementation file for Child

    BEGIN_MESSAGE_MAP(Child,Parent)
        ON_REGISTERED_MESSAGE(MyRegMsg,MyHandler)
    END_MESSAGE_MAP()

    // MyHandler implementation....

    On compiling the project, I get the following compiler error:
    error C2440: 'type cast' : cannot convert from 'long (__thiscall Child::*)(long,unsigned int)' to 'long (__thiscall CWnd::*)(unsigned int,long)'

    Where have I gone wrong in the above implementation ?
    Does Child class need to be direct derivative of CWnd class to declare a message map ?

    I'm using VC++ 6.0 with SP4.

    Thanks,
    Pavan
    • Edited by Option Greek Friday, June 6, 2008 12:47 PM Have to provide vc++ compiler version
    Friday, June 6, 2008 12:43 PM

Answers

All replies