CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 1999
    Location
    Singapore
    Posts
    34

    Interesting!! - Inheritance problem

    THE SOULUTION IN THE REPLY GIVEN TO THIS MESSAGE BY ANONYM DID NOT WORK !!!
    HI,

    I am writting a DLL of custom controls. i.e. some additional features added to existing windows controls. So I have written this CMyListCtrl class that enhances CListCtrl MFC class. The class is exported as following :

    class __declspec(dllexport) CMyListCtrl : public CListCtrl
    {
    //class body goes here
    };

    The dll is created without any problems.

    I can use this dll and the control class in other applications, and make use of CMyListCtrl where ever I can. There is no problem in it.

    The problem starts when I try to inherit another class from CMyListCtrl in some other application.

    For e.g. I create another project import the dll of custom controls.
    Then I write a class as following:

    class CAnotherListCtrl : public CMyListCtrl
    {
    //class body.
    };

    When I compile the application linker gives me following error :

    TestListCtrl.obj : error LNK2001: unresolved external symbol "protected: static struct AFX_MSGMAP const CMyListCtrl::messageMap" (?messageMap@CMyListCtrl@@1UAFX_MSGMAP@@B)
    Debug/DLLUseTest.exe : fatal error LNK1120: 1 unresolved externals

    I suspected it is because of the DECLARE_MESSAGE_MAP() or BEGIN_MESSAGE_MAP() macros. So I changed the BEGIN_MESSAGE_MAP macro from :

    BEGIN_MESSAGE_MAP(CAnotherListCtrl, CMyListCtrl)

    to

    BEGIN_MESSAGE_MAP(CAnotherListCtrl, CListCtrl)

    and the error was gone. But obviously all the message handling in CMyListCtrl was gone.

    Does anybody know whats happening ? So the basic question would be 'How do we write a library of Custom controls (inherited from MFC) that can be used to further define new clasees ?'

    Is this because something is not getting exported properly ?

    Please feedback

    Sanjeet.


  2. #2
    Guest

    Re: Interesting!! - Inheritance problem

    You must select project type of MFC Extension DLL. This adds the additional macros to that if you declare your class as AFX_EXT_CLASS it will have it's message maps exported as well.


  3. #3
    Join Date
    Apr 1999
    Location
    Singapore
    Posts
    34

    Re: Interesting!! - Inheritance problem

    No it did not work.

    I am still getting the same error!

    This is what I did :

    I created a new project with type MFC Extention DLL.

    Then I declared my class as AFX_EXT_CLASS (this macro is nothing but
    __declspec(dllexport) that I already had otherwise my class members wouldn't have been exported in the first place.) But anyway I changed it to AFX_EXT_CLASS. Then I used the class in other application.
    Still the error remains.

    What could be going wrong ?

    Cheers
    Sanjeet


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured