共用方式為


CAsyncMonikerFile::OnDataAvailable

An asynchronous moniker calls OnDataAvailable to provide data to the client as it becomes available, during asynchronous bind operations.

virtual void OnDataAvailable( 
   DWORD dwSize, 
   DWORD bscfFlag  
);

Parameters

  • dwSize
    The cumulative amount (in bytes) of data available since the beginning of the binding. Can be zero, indicating that the amount of data is not relevant to the operation, or that no specific amount became available.

  • bscfFlag
    A BSCF enumeration value. Can be one or more of the following values:

    • BSCF_FIRSTDATANOTIFICATION   Identifies the first call to OnDataAvailable for a given bind operation.

    • BSCF_INTERMEDIATEDATANOTIFICATION   Identifies an intermediary call to OnDataAvailable for a bind operation.

    • BSCF_LASTDATANOTIFICATION   Identifies the last call to OnDataAvailable for a bind operation.

Remarks

The default implementation of this function does nothing. See the following example for a sample implementation.

Example

void CMyMoniker::OnDataAvailable(DWORD dwSize, DWORD bscfFlag)
{
   if ((bscfFlag & BSCF_FIRSTDATANOTIFICATION) != 0)
   {
      m_dwReadBefore = 0;
      m_strText.Empty();
   }

   DWORD dwArriving = dwSize - m_dwReadBefore;

   if (dwArriving > 0)
   {
      int nLen = m_strText.GetLength();
      ASSERT((DWORD)nLen == m_dwReadBefore);
      LPTSTR psz = m_strText.GetBuffer(nLen + dwArriving);
      Read(psz + nLen, dwArriving);
      m_strText.ReleaseBuffer(nLen + dwArriving);
      m_dwReadBefore = dwSize;
   }
}

Requirements

Header: afxole.h

See Also

Reference

CAsyncMonikerFile Class

Hierarchy Chart

CDataPathProperty Class

Other Resources

CAsyncMonikerFile Members