// AsynchText.cpp : implementation file
//

#include "stdafx.h"
#include "atext.h"
#include "AsynchText.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAsynchText

IMPLEMENT_DYNAMIC(CAsynchText, CCachedDataPathProperty)

CAsynchText::CAsynchText(COleControl* pControl)
    : CCachedDataPathProperty(pControl)
{
}

CAsynchText::~CAsynchText()
{
}


// Do not edit the following lines, which are needed by ClassWizard.
#if 0
BEGIN_MESSAGE_MAP(CAsynchText, CCachedDataPathProperty)
	//{{AFX_MSG_MAP(CAsynchText)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif	// 0

/////////////////////////////////////////////////////////////////////////////
// CAsynchText member functions

DWORD CAsynchText::GetBindInfo() const
{
	return BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA ;
}

void CAsynchText::OnDataAvailable(DWORD dwSize, DWORD bscfFlag) 
{
/*
Call base class, which reads the data into a memory file.
*/
	
	CCachedDataPathProperty::OnDataAvailable(dwSize, bscfFlag);

/*
Invalidate the contorl to which we belong to force a repaint.
*/
	GetControl( ) -> Invalidate( ) ;

/*
If the flags indicate that this is the las OnDataAvailable( ) notification,
then set ReadyState property and trigger the ReadyStateChanged event. 
*/

	if (bscfFlag && BSCF_LASTDATANOTIFICATION)
	{
		GetControl( ) -> InternalSetReadyState (READYSTATE_COMPLETE) ;
	}
}
