CBindStatusCallback::StartAsyncDownload

HRESULT StartAsyncDownload( T* pT, ATL_PDATAAVAILABLE pFunc, BSTR bstrURL, BOOL bRelative = FALSE );

Return Value

One of the standard HRESULT values.

Parameters

pT

[in] A pointer to the object requesting the asynchronous data transfer. The CBindStatusCallback object is templatized on this object's class.

pFunc

[in] A pointer to the function that receives the data being read. The function is a member of your object's class of type T. See Remarks for syntax and an example.

bstrURL

[in] The URL to obtain data from. Can be any valid URL or file name. Cannot be NULL. For example:

CComBSTR mybstr =_T("http://somesite/data.htm")

pUnkContainer

[in] The IUnknown of the container. NULL by default.

bRelative

[in] A flag indicating whether the URL is relative or absolute. FALSE by default, meaning the URL is absolute.

Remarks

Starts downloading data asynchronously from the specified URL. Every time data is available it is sent to the object through OnDataAvailable. OnDataAvailable reads the data and calls the function pointed to by pFunc (for example, to store the data or print it to the screen).

The function pointed to by pFunc is a member of your object's class and has the following syntax:

void Function_Name( CBindStatusCallback<T>* pbsc, BYTE* pBytes, DWORD dwSize );

In the following example (taken from the ASYNC sample), the function OnData writes the received data into a text box:

void OnData(CBindStatusCallback<CATLAsync>* pbsc, 
            BYTE* pBytes, DWORD dwSize)
{
   m_bstrText.Append= (LPCSTR)pBytes;
   if (::IsWindow(m_EditCtrl.m_hWnd))
   {
      USES_CONVERSION;
      ::SendMessage(m_EditCtrl.m_hWnd, WM_SETTEXT, 0, 
                    (LPARAM)OLE2CT((BSTR)m_bstrText));
   }
}

CBindStatusCallback OverviewClass Members

See Also   CBindStatusCallback::OnDataAvailable