Ejemplo n.º 1
0
void CZipArchive::myfree(void* opaque, void* address)
{
	if (opaque)
	{
		CPtrList* list  = (CPtrList*) opaque;
		POSITION pos = list->Find(address);
		if (pos)
			list->RemoveAt(pos);
	}
	delete[] address;
}
Ejemplo n.º 2
0
void ChatDialog::OnExit(TNotifyUI& msg)
{
	thelockChatDlgList.Lock();
	POSITION pos,temp;
	for (pos=theChatDialogList.GetHeadPosition();pos!=NULL;)
	{
		temp = pos;
		ChatDialog* pDlg = (ChatDialog*)theChatDialogList.GetNext(pos);
		if (pDlg&&pDlg==this)
		{
			theChatDialogList.RemoveAt(temp);
		}
	}
	thelockChatDlgList.UnLock();
	Close();
}
Ejemplo n.º 3
0
void CDlgFreeTrainList::OnDel() 
{
  if(m_ctlList.GetSelectedCount()!=1)
    return;

  if(::AfxMessageBox("是否删除自由行车?",MB_YESNO)==IDNO)
    return;

  POSITION pos = m_ctlList.GetFirstSelectedItemPosition();
  int item = m_ctlList.GetNextSelectedItem(pos);
  g_FreeTrainManageList.RemoveAt(g_FreeTrainManageList.FindIndex(item));

  g_LastSelected = m_ctlList.GetNextSelectedItem(pos);
	g_LastSelected++;
  UpdateList();
  ::SelectListItem(m_ctlList,g_LastSelected);
	
}
Ejemplo n.º 4
0
CDuiWkeView::~CDuiWkeView()
{
	if(m_hwndHost != NULL)
	{
		::DestroyWindow(m_hwndHost);
	}

	// 删除wke对象列表中的项
	int count = g_duiWkeViews.GetCount();
	for(int i = 0; i < count; i ++)
	{
		POSITION pos = g_duiWkeViews.FindIndex(i);
		CDuiWkeView* pDuiWkeView = (CDuiWkeView*)g_duiWkeViews.GetAt(pos);
		if(pDuiWkeView == this) 
		{
			g_duiWkeViews.RemoveAt(pos);
			return;
		}
	}
}
Ejemplo n.º 5
0
//删除客户端
void CTCPServer_CE::RemoteClient(CTCPCustom_CE *pClient /*客户端对象*/)
{
	POSITION posPrior;
	POSITION pos = m_ListClientSocket.GetHeadPosition();

	while (pos != NULL)
	{
		posPrior = pos;
        CTCPCustom_CE *pTcpCustom = (CTCPCustom_CE*)m_ListClientSocket.GetNext(pos);
		if (pTcpCustom == pClient)
		{
			//释放内存
			delete pTcpCustom;
			pTcpCustom = NULL;
			m_ListClientSocket.RemoveAt(posPrior);
			TRACE(L"移出了一个客户端对象\n");
			break;
		}
	}
}
Ejemplo n.º 6
0
void KDicomDS::DeleteElement(KDicomElement * pDE, KDicomElement * pParent)
{
    CPtrList * pList;
    if(pParent == NULL)
        pList = & m_listDE;
    else
        pList = &(pParent->m_listDE);

    KDicomElement * pDET;
    POSITION p_pos;
    POSITION pos = pList->GetHeadPosition();
    while(pos != NULL) {
        p_pos = pos;
        pDET = (KDicomElement *) pList->GetNext(pos);
        if(pDET == pDE) {
            pList->RemoveAt(p_pos);
            delete pDE;
            return;
        }
    }
}
Ejemplo n.º 7
0
BOOL IPM_BuildItemPath (CdIpmDoc* pDoc, CTypedPtrList<CObList, CuIpmTreeFastItem*>& listItemPath)
{
	ASSERT(!pDoc->GetSelectKey().IsEmpty());
	if (pDoc->GetSelectKey().IsEmpty())
		return FALSE;

	BOOL bOK = FALSE;
	int  nLevel = 0;
	int  nParent0type = 0;
	int  nObjectType  = 0;
	CString strParent0 = _T("");
	CString strStaticParent = _T("");
	CStringArray& arrayItemPath = pDoc->GetItemPath();
	void* pStructParent = NULL;
	int narrayItemPathSize = arrayItemPath.GetSize();
	ASSERT(narrayItemPathSize >= 1);
	if (narrayItemPathSize < 1)
		return FALSE;
	CString strObject = arrayItemPath.GetAt(0);
	//
	// Default (from old class CuIpmObjDesc in vdba):
	BOOL bObjectNeedsNameCheck = FALSE;
	BOOL bObjectHasStaticBranch= TRUE;
	BOOL bStaticParentNeedsNameCheck= FALSE;

	if (pDoc->GetSelectKey().CompareNoCase (_T("SERVER")) == 0)
	{
		//
		// Old class CuIpmObjDesc_SERVER in vdba (no overwrite the 3 default booleans above.
		nObjectType  = OT_MON_SERVER;
	}
	else
	if (pDoc->GetSelectKey().CompareNoCase (_T("SESSION")) == 0)
	{
		//
		// Old class CuIpmObjDesc_SESSION in vdba (no overwrite the 3 default booleans above.
		nLevel = 1; // Parent is the SERVER. EX: ii\ingres\158
		nParent0type = OT_MON_SERVER;
		nObjectType  = OT_MON_SESSION;
		ASSERT(narrayItemPathSize >= 2);
		if (narrayItemPathSize < 2)
			return FALSE;
		strParent0   = arrayItemPath.GetAt(0);
		strObject    = arrayItemPath.GetAt(1);
	}
	else
	if (pDoc->GetSelectKey().CompareNoCase (_T("REPLICSERVER")) == 0)
	{
		//
		// Old class CuIpmObjDesc_REPLICSERVER in vdba (overwrite the 2 default booleans above.
		bStaticParentNeedsNameCheck = TRUE;
		bObjectHasStaticBranch = FALSE;
		nLevel = 1; // Parent is the database name
		nParent0type = OT_DATABASE;
		nObjectType  = OT_MON_REPLIC_SERVER;
		ASSERT(narrayItemPathSize >= 1);
		if (narrayItemPathSize < 1)
			return FALSE;
		strStaticParent = _T("Replication");
		strParent0   = arrayItemPath.GetAt(0);
		if (narrayItemPathSize > 1)
			strObject    = arrayItemPath.GetAt(1);
	}
	else
	if (pDoc->GetSelectKey().CompareNoCase (_T("LOGINFO")) == 0)
	{
		//
		// Old class CuIpmObjDesc_LOGINFO in vdba (overwrite the 1 default boolean above.
		bObjectNeedsNameCheck = TRUE;
		strObject.LoadString(IDS_TM_LOGINFO); // "Log information"
	}

	if (nLevel > 0)
	{
		ASSERT (nParent0type);
		ASSERT (!strParent0.IsEmpty());
		// Static parent
		if (bStaticParentNeedsNameCheck) 
		{
			//
			// Only for replication:
			listItemPath.AddTail(new CaTreeItemPath(TRUE, nParent0type, NULL, TRUE, strStaticParent));
		}
		else
		{
			listItemPath.AddTail(new CaTreeItemPath(TRUE, nParent0type));
		}

		int reqSize = IPM_StructSize(nParent0type);
		CPtrList listInfoStruct;
		IPMUPDATEPARAMS ups;
		memset (&ups, 0, sizeof(ups));
		CaIpmQueryInfo queryInfo(pDoc, nParent0type, &ups, (LPVOID)NULL, reqSize);
		queryInfo.SetReportError(FALSE);

		bOK = IPM_QueryInfo (&queryInfo, listInfoStruct);
		if (bOK)
		{
			POSITION p = NULL, pos = listInfoStruct.GetHeadPosition();

			while (pos != NULL)
			{
				p = pos;
				LPVOID pObject = listInfoStruct.GetNext(pos);
				if (MatchedStruct (nParent0type, strParent0, pObject))
				{
					pStructParent = pObject;
					listInfoStruct.RemoveAt (p);
					listItemPath.AddTail(new CaTreeItemPath(FALSE, nParent0type, pObject)); // non-static
					break;
				}
			}
			while (!listInfoStruct.IsEmpty())
				delete listInfoStruct.RemoveHead();
		}

		if (!pStructParent)
			return FALSE;
	}

	//
	// Object itself:
	if (strObject.IsEmpty())
		return bOK;

	if (bObjectNeedsNameCheck)
	{
		listItemPath.AddTail(new CaTreeItemPath(TRUE,  nObjectType, NULL, TRUE, strObject));  // Root item
		bOK = TRUE;
	}
	else
	{
		if (bObjectHasStaticBranch)
			listItemPath.AddTail(new CaTreeItemPath(TRUE, nObjectType));  // static

		int reqSize = IPM_StructSize(nObjectType);
		CPtrList listInfoStruct;
		IPMUPDATEPARAMS ups;
		memset (&ups, 0, sizeof(ups));
		ups.nType   = nParent0type;
		ups.pStruct = pStructParent;
		ups.pSFilter= NULL;

		CaIpmQueryInfo queryInfo(pDoc, nObjectType, &ups, (LPVOID)NULL, reqSize);
		queryInfo.SetReportError(FALSE);

		BOOL bHasObjects = IPM_QueryInfo (&queryInfo, listInfoStruct);
		if (bHasObjects)
		{
#if !defined (_IGNORE_NOT_MATCHED_ITEM)
			bOK = FALSE;
#endif
			POSITION p = NULL, pos = listInfoStruct.GetHeadPosition();
			while (pos != NULL)
			{
				p = pos;
				LPVOID pObject = listInfoStruct.GetNext(pos);
				if (MatchedStruct (nObjectType, strObject, pObject))
				{
					bOK = TRUE;
					listInfoStruct.RemoveAt (p);
					listItemPath.AddTail(new CaTreeItemPath(FALSE, nObjectType, pObject)); // non-static
					break;
				}
			}
			while (!listInfoStruct.IsEmpty())
				delete listInfoStruct.RemoveHead();
		}
	}

	return bOK;
}