//设定消息处理的窗口句柄
HttpDown.SetParentWindow(hwnd);
//添加要下载的文件路径
HttpDown.AddFile();
//开始下载
m_HttpDown.BeginDownLoad();
//这两个函数都是消息通知,自己添加自定义消息处理
LRESULT CAutoUpdateDlg::EndDown(WPARAM wParam, LPARAM lParam)
{
	//下载完成以后调用的函数
	return 0;
}
LRESULT CAutoUpdateDlg::OnDisplayStatus(WPARAM wParam, LPARAM lParam)
{
	//处理下载进度的函数
	const DOWNLOADSTATUS *const pDownloadStatus =
		reinterpret_cast<DOWNLOADSTATUS *>(lParam);
	CString strStatus;
	if (pDownloadStatus != NULL)
	{
#ifdef _DEBUG
		VERIFY(strStatus.LoadString(pDownloadStatus->ulStatusCode -
			UF_BINDSTATUS_FIRST +
			IDS_BINDSTATUS01));
		strStatus += _T("  ");
		strStatus += pDownloadStatus->szStatusText;
		CString strProgress;
		strProgress.Format(_T(" %lu of %lu"),
			pDownloadStatus->ulProgress,
			pDownloadStatus->ulProgressMax);
		strStatus += strProgress + _T("\r\n");
		TRACE(strStatus);
#endif
		m_Progress.SetPos(MAX_PROGRESS_NUM/((pDownloadStatus->ulProgressMax/(pDownloadStatus->ulProgress+1))+1));
	}
	return 0;
}
		//下载失败我就在函数里处理关闭主窗口,具体自己实现
		// empty the filename string if failed or canceled
		if (!SUCCEEDED(hr))
		{
			strFileName.ReleaseBuffer(-1);
			pThis->m_DownList.clear();
			//如果下载失败或是取消下载就关闭窗口
			::PostMessage(pThis->m_hWnd, WM_CLOSE, 0, 0);
			return 0;
		}  
回复  更多评论