Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

AfxDoForAllObjects

 

Executes the specified iteration function for all objects derived from CObject that have been allocated with new.


      void AfxDoForAllObjects(
   void (*pfn
)(CObject* pObject,
   void* pContext
),
   void* pContext 
); 

pfn

Points to an iteration function to execute for each object. The function arguments are a pointer to a CObject and a void pointer to extra data that the caller supplies to the function.

pContext

Points to optional data that the caller can supply to the iteration function. This pointer can be NULL.

Stack, global, or embedded objects are not enumerated. The pointer passed to AfxDoForAllObjects in pContext is passed to the specified iteration function each time it is called.

System_CAPS_noteNote

This function works only in the Debug version of MFC.

Example

#ifdef _DEBUG
void DoForAllObjects(CObject* pObject, void* pContext)
{
   int *pnCount = (int*)pContext;

   pObject->AssertValid();
   if (pnCount != NULL)
      (*pnCount)++;
}
#endif // _DEBUG
#ifdef _DEBUG
   //AfxDoForAllObjects will call the function DoForAllObjects 
   //For each CObject-derived object that is allocated on the heap
   int nCount = 0;
   AfxDoForAllObjects(DoForAllObjects, &nCount);
   TRACE("%d Objects Checked\n", nCount);
#endif

Requirements

Header: afx.h

Show: