Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Customized BEGIN_TEMPLATE_MESSAGE_MAP with 2 template arguments for VS2005

Customized BEGIN_TEMPLATE_MESSAGE_MAP with 2 template arguments for VS2005

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++visual-studiohelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    funwithdolphin
    wrote on last edited by
    #1

    Hi, I am getting below compiler error on Visual Studio 2005: isodirbrowserlistctrl.cpp(46) : error C2906: 'const AFX_MSGMAP *CListDataCtrl<B,T>::GetThisMessageMap(void)' : explicit specialization requires 'template <>' with [B=CListCtrl,T=CBrowserListCtrlData Here is the code with .h and .cpp files. This code used to compile and run fine on Visual Studio 6.0. I guess I need to use BEGIN_TEMPLATE_MESSAGE_MAP. But BEGIN_TEMPLATE_MESSAGE_MAP can not handle more than one template arguments. In my case, there are 2 template arguments.

    // ListDataCtrl.h : header file
    //
    class CListDataBase
    {
    public:
    CListDataBase() : m_iItem(-1), m_pCtl(0) {};
    void SetControl(CListCtrl* pCtl) { m_pCtl = pCtl; }
    CListCtrl* GetControl() { return m_pCtl; }
    void SetItemNumber(int iItem) { m_iItem = iItem; }
    int GetItemNumber() { return m_iItem; }

    protected:
    int m_iItem;
    CListCtrl *m_pCtl;
    };
    ////////////////////////////////////////////////////////////////////////////
    // CListDataCtrl window

    template <class B, class T>
    class CListDataCtrl : public B
    {
    // Construction
    public:
    CListDataCtrl() {};
    // Attributes
    public:
    // Operations
    public:
    T* GetListData(int iItem)
    {
    T *pResult = (T*) GetItemData(iItem);
    return pResult;
    }

    void DeleteListDataPrim(int iItem)
    {
    	T\* pData = (T\*) GetItemData(iItem);
    	delete pData; pData = 0;
    	SetItemData(iItem, 0);
    }
    
    void DeleteListData(int iItem)
    {
    	DeleteListDataPrim(iItem); 
    }
    
    BOOL DeleteListNode(int iItem)
    {
    	DeleteListData(iItem);
    	return DeleteItem(iItem);
    }
    void SetListData(int iItem, T\* pData)
    {
    	pData->SetItemNumber(iItem);
    	pData->SetControl(this);
    	DeleteListData(iItem);
    	SetItemData(iItem, (DWORD) pData);
    }
    
    void DeleteAllListData()
    {
    	int cMax = GetItemCount();
    	for (int i=0; i<cMax; i++)
    	{
    		delete (T\*) GetItemData(i);
    		SetItemData(i, 0);
    	}
    }
    
    void DeleteEntireList()
    {
    	DeleteAllListData();
    	DeleteAllItems();
    }
    
    T\* InsertItemData(LPCTSTR ptszText, int iItem, T\* pData = 0)
    {
    	if (!pData)
    	{
    		pData = new T;
    	}
    	int iNewItem = InsertItem(iItem, ptszText);
    	SetListData(iNewItem, pData);
    	return pData;
    }
    

    // Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CListDataCtrl)
    //}}AFX_VIRTUAL
    // Implementation
    public:
    virtual ~CListDataCtrl() {};
    // Generated message map functions
    protected:
    //{{AFX_MSG(CListDataCtrl)
    // NOTE - the ClassWizard will add and remove member

    C 1 Reply Last reply
    0
    • F funwithdolphin

      Hi, I am getting below compiler error on Visual Studio 2005: isodirbrowserlistctrl.cpp(46) : error C2906: 'const AFX_MSGMAP *CListDataCtrl<B,T>::GetThisMessageMap(void)' : explicit specialization requires 'template <>' with [B=CListCtrl,T=CBrowserListCtrlData Here is the code with .h and .cpp files. This code used to compile and run fine on Visual Studio 6.0. I guess I need to use BEGIN_TEMPLATE_MESSAGE_MAP. But BEGIN_TEMPLATE_MESSAGE_MAP can not handle more than one template arguments. In my case, there are 2 template arguments.

      // ListDataCtrl.h : header file
      //
      class CListDataBase
      {
      public:
      CListDataBase() : m_iItem(-1), m_pCtl(0) {};
      void SetControl(CListCtrl* pCtl) { m_pCtl = pCtl; }
      CListCtrl* GetControl() { return m_pCtl; }
      void SetItemNumber(int iItem) { m_iItem = iItem; }
      int GetItemNumber() { return m_iItem; }

      protected:
      int m_iItem;
      CListCtrl *m_pCtl;
      };
      ////////////////////////////////////////////////////////////////////////////
      // CListDataCtrl window

      template <class B, class T>
      class CListDataCtrl : public B
      {
      // Construction
      public:
      CListDataCtrl() {};
      // Attributes
      public:
      // Operations
      public:
      T* GetListData(int iItem)
      {
      T *pResult = (T*) GetItemData(iItem);
      return pResult;
      }

      void DeleteListDataPrim(int iItem)
      {
      	T\* pData = (T\*) GetItemData(iItem);
      	delete pData; pData = 0;
      	SetItemData(iItem, 0);
      }
      
      void DeleteListData(int iItem)
      {
      	DeleteListDataPrim(iItem); 
      }
      
      BOOL DeleteListNode(int iItem)
      {
      	DeleteListData(iItem);
      	return DeleteItem(iItem);
      }
      void SetListData(int iItem, T\* pData)
      {
      	pData->SetItemNumber(iItem);
      	pData->SetControl(this);
      	DeleteListData(iItem);
      	SetItemData(iItem, (DWORD) pData);
      }
      
      void DeleteAllListData()
      {
      	int cMax = GetItemCount();
      	for (int i=0; i<cMax; i++)
      	{
      		delete (T\*) GetItemData(i);
      		SetItemData(i, 0);
      	}
      }
      
      void DeleteEntireList()
      {
      	DeleteAllListData();
      	DeleteAllItems();
      }
      
      T\* InsertItemData(LPCTSTR ptszText, int iItem, T\* pData = 0)
      {
      	if (!pData)
      	{
      		pData = new T;
      	}
      	int iNewItem = InsertItem(iItem, ptszText);
      	SetListData(iNewItem, pData);
      	return pData;
      }
      

      // Overrides
      // ClassWizard generated virtual function overrides
      //{{AFX_VIRTUAL(CListDataCtrl)
      //}}AFX_VIRTUAL
      // Implementation
      public:
      virtual ~CListDataCtrl() {};
      // Generated message map functions
      protected:
      //{{AFX_MSG(CListDataCtrl)
      // NOTE - the ClassWizard will add and remove member

      C Offline
      C Offline
      Code o mat
      wrote on last edited by
      #2

      See if this[^] can help.

      > The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <

      F 1 Reply Last reply
      0
      • C Code o mat

        See if this[^] can help.

        > The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <

        F Offline
        F Offline
        funwithdolphin
        wrote on last edited by
        #3

        I looked at it. But it has Customized BEGIN_TEMPLATE_MESSAGE_MAP only for VC7. It doesn't have mention of Customized BEGIN_TEMPLATE_MESSAGE_MAP for VS2005/VC8.

        C 1 Reply Last reply
        0
        • F funwithdolphin

          I looked at it. But it has Customized BEGIN_TEMPLATE_MESSAGE_MAP only for VC7. It doesn't have mention of Customized BEGIN_TEMPLATE_MESSAGE_MAP for VS2005/VC8.

          C Offline
          C Offline
          Code o mat
          wrote on last edited by
          #4

          Well, other than "extracting" the macros yourself and adding the template parameters where needed i have no better idea yet if those don't work for VS2005/8 as you said...

          > The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups