www.pudn.com > DrawerMenu(ÍêÕû°æ).rar > SuperItem.cpp
// SuperItem.cpp: implementation of the CSuperItem class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "DrawerMenu.h"
#include "SuperItem.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CSuperItem::CSuperItem(int nItemID, CString & strText, int nCurSel)
{
m_nItemID = nItemID;
m_strText = strText;
m_nCurSel = nCurSel;
}
CSuperItem::~CSuperItem()
{
int index = m_subItems.GetSize();
while(index) { delete (m_subItems[--index]); }
m_subItems.RemoveAll();
}
BOOL CSuperItem::AddSubItem(int nItemID, int nImageIndex, CString & strText)
{
CSubItem * psi = NULL;
try
{
psi = new CSubItem(nItemID, nImageIndex, strText);
m_subItems.Add(psi);
}
catch(CMemoryException * e)
{
AfxMessageBox(_T("CSuperItem : Out of memory !"));
if(psi != NULL)
{
delete psi;
psi = NULL;
}
e->Delete();
return FALSE;
}
return TRUE;
}