Customized BEGIN_TEMPLATE_MESSAGE_MAP with 2 template arguments for VS2005
-
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 windowtemplate <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 -
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 windowtemplate <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> 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. <
-
> 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. <
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.
-
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.
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. <