15,979
社区成员
发帖
与我相关
我的任务
分享
//创建对象
CDlgInfoItem* pItemNew = new CDlgInfoItem;
pItemNew->m_nDlgIndex = nDlgIndex;
pItemNew->m_pDlgVideo = new CDlgVideo(nDlgIndex);
pItemNew->m_pDlgVideo->Create(IDD_DIALOG_VIDEO, NULL);
CString strMsg;
strMsg.Format(_T("视频%d"), nDlgIndex);
pItemNew->m_pDlgVideo->SetWindowText(strMsg);
pItemNew->m_pDlgVideo->ShowWindow(SW_SHOW);
g_DlgInfoList.AddTail(pItemNew);
//删除对象
POSITION pos = g_DlgInfoList.GetHeadPosition();
POSITION posPre = pos;
while (pos != NULL)
{
CDlgInfoItem *pItem = (CDlgInfoItem*)g_DlgInfoList.GetNext(pos);
DisConnect(pItem->m_nDlgIndex);
if (pItem->m_pDlgVideo)//该对话框指针对象不为空
{
pItem->m_pDlgVideo->DestroyWindow();//销毁窗口,在销毁窗口时会把其它对象的窗口也销毁
delete pItem->m_pDlgVideo;//删除对象
pItem->m_pDlgVideo = NULL;//释放指针
}
delete g_DlgInfoList.GetAt(posPre);//释放链表数据指针
g_DlgInfoList.RemoveAt(posPre);//移除链表数据
posPre = pos;
}
CDlgInfoItem *pItem = (CDlgInfoItem*)g_DlgInfoList.GetNext(pos);
pos = g_DlgInfoList.GetHeadPosition();
[/quote]
是我代码贴错了,这个删除只是删一个的,删除其中一个链表对象,删除后就break跳出了,不会执行下去了。CDlgInfoItem *pItem = (CDlgInfoItem*)g_DlgInfoList.GetNext(pos);
pos = g_DlgInfoList.GetHeadPosition();