Dedicated to download to a local disk, display the progress bar to use this class, first get ChttpClient download class // httpclientProcess.h: Dedicated to download to local disks, display progress bar ////
#if! defined (AFX_HTTPCLIENTPROCESS_H __) # Define AFX_HTTPCLIENTPROCESS_H__
#include "httpclient.h"
Class ChttpClientProcess: public chttpclient {public: chttpclientProcess (); virtual ~ chttpclientprocess ();
Bool Download (Char * URL, CHAR * FNAME, VOID * P); // P. Pointer Virtual Void ONDATARECIVED (CHAR * DATA, Long DataSize, int first = false); private: cprogressctrl * m_lpprocessbar;
#ENDIF / / ---------------------------------------------- -------------------- // httpClientProcess.cpp ////
#include "stdafx.h" #include "httpclientprocess.h"
ChttpClientProcess :: chttpclientprocess () {m_lpprocessbar = null;}
ChttpClientProcess :: ~ chttpclientprocess () {
} Void ChttpClientProcess :: Ondatarecived (Char * Data, Long DataSize, Int First) {ChttpClient :: Ondatarecived (Data, DataSize, First); if (! m_lpprocessbar) return;
IF (first) {char Buf [128]; MEMSET (BUF, 0, 128); GetHeader ("Content-Length", BUF); M_LpprocessBar-> setRANGE32 (0, Atol (BUF)); m_lpprocessbar-> setpos (dataize); } Else {m_lpprocessbar-> setpos (m_lpprocessbar-> getpos () dataize);}}
Bool ChttpClientProcess :: Download (Char * URL, Char * FNAME, VOID * P) {m_lpprocessbar = (cprogressctrl *) p; Return ChttpClient :: Download (URL, FNAME);