//////////////////////////////////////////////////////////////////////
//
// Written by Michael Dunn (mdunn at inreach dot com).  Copyright and all
// that stuff.  Use however you like but give me credit where it's due.  I'll
// know if you don't. bwa ha ha ha ha!
// 
// Release history:
//   December 24, 1999: Version 1.0.  First release.
//
//////////////////////////////////////////////////////////////////////

// BindStatusCallback.cpp: implementation of the CBindStatusCallback class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include <urlmon.h>
#include <shlwapi.h>                    // for StrFormatByteSize()
#include "BindStatusCallback.h"

LONG g_fAbortDownload = 0;

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

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CCallback::CCallback()
{
}

CCallback::~CCallback()
{
}

HRESULT CCallback::OnProgress ( ULONG ulProgress,   ULONG ulProgressMax,
                                ULONG ulStatusCode, LPCWSTR wszStatusText )
{
    UNREFERENCED_PARAMETER(ulStatusCode);

    // Did the user hit the Stop button?
    if ( 0 != g_fAbortDownload )
        return E_ABORT;

#ifdef _DEBUG
// Local variables are declared static so they don't have to be reallocated on
// the stack every time.  This is safe in this app since I know I'll only have
// one thread downloading.
static TCHAR   sIEStatusMsg[256];
static TCHAR   szCustomStatusMsg [256];

    // Use CString to convert IE's status message to a TCHAR string.
    if ( NULL != wszStatusText )
        {
//        lstrcpy(sIEStatusMsg, wszStatusText);
        }
    else
        {
        sIEStatusMsg[0] = 0;
        }

    if ( 0 != ulProgressMax )
        {
        wsprintf ( szCustomStatusMsg, "Downloaded %ld of %ld",
                   ulProgress, ulProgressMax);
        }
    else
        {
        wsprintf ( szCustomStatusMsg, "Downloaded %ld (total size unknown)",
                   ulProgress);
        }

	OutputDebugString(sIEStatusMsg);		OutputDebugString("\n");
	OutputDebugString(szCustomStatusMsg);	OutputDebugString("\n");
#endif

    return S_OK;
}
