Click here to Skip to main content
15,915,172 members
Articles / Desktop Programming / MFC
Article

CHttpDownloadDlg v1.03

Rate me:
Please Sign up or sign in to vote.
4.81/5 (18 votes)
3 Mar 2000 216.6K   5.7K   97   51
A dialog implementation that performs HTTP downloads.
  • Download source files - 42 Kb
  • Sample Image - DownloadDlg.gif

    Introduction

    Welcome to CHttpDownloadDlg, an MFC dialog which performs HTTP downloads similar to the Internet Explorer download dialog as shown above.


    History
    Usage
    Contacting the Author


    History

    V1.0 (14 November 1999)
    • First public release.

    V1.01 (15 November 1999)

    • Updated documentation to refer to what rc resources are needed by the class.
    • Renamed all resources used from ASYNC_DOWLOAD to include HTTPDOWNLOAD.
    • Now handles HTTP error 407 (Proxy Authentication) and HTTP error 401 (Server Authentication). You are prompted with a password dialog when either of these forms of authentication are required.
    • Sample program now allows you to specify the URL to download from as well as the file to download into and the username and password to connect with.
    • The download file is now deleted if the download was aborted or if some other error occurs during the download.
    • Parsing of URL will now work where "http://" is not explicitely specified.
    • Improved the general look and feel of the demo app and called it "HTML File Downloader".

    V1.02 (29 November 1999)

    • Fixed a number of compiler warnings and errors when used in VC++ 6.0.

    V1.03 (25 January 2000)

    • Fixed a problem where server authentication was not being detected correctly, while proxy authentication was being handled.
    • Updated the way and periodicity certain UI controls are updated during the HTTP download.


    Usage

    To use CHttpDownloadDlg in your project simply include HttpDownloadDlg.cpp/.h from the test application in your application and #include "HttpDownloadDlg.h" in whichever files you want to use the class in. To bring up the dialog to download a specific file, just use some code like the following:

    CHttpDownloadDlg dlg;
    dlg.m_sURLToDownload = _T("http://www.some-site.com/somefile.ext");
    dlg.m_sFileToDownloadInto = _T("c:\\somfile.ext");
    if (dlg.DoModal() == IDOK)
       AfxMessageBox("File was downloaded successfully");

    You should also have a look at the CInetDownloadDlg::OnDownload() code in the sample application.


    Contacting the Author

    PJ Naughter
    Email: pjn@indigo..ie
    Web: http://www.naughter.com
    25 January 2000


    License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here


    Written By
    United States United States
    This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

    Comments and Discussions

     
    GeneralMy vote of 4 Pin
    minsikchu8-Sep-10 15:02
    minsikchu8-Sep-10 15:02 
    QuestionHow to copy the res? Pin
    rootdial5-Apr-06 8:42
    rootdial5-Apr-06 8:42 
    Generaltoo many errors Pin
    petri11123-Oct-04 7:17
    petri11123-Oct-04 7:17 
    GeneralRe: too many errors Pin
    pjnaughter23-Oct-04 10:50
    pjnaughter23-Oct-04 10:50 
    GeneralRe: too many errors Pin
    petri11128-Oct-04 18:22
    petri11128-Oct-04 18:22 
    GeneralRe: too many errors Pin
    pjnaughter29-Oct-04 1:06
    pjnaughter29-Oct-04 1:06 
    GeneralRe: too many errors Pin
    KarstenK13-Jul-05 23:11
    mveKarstenK13-Jul-05 23:11 
    GeneralRe: too many errors Pin
    pjnaughter14-Jul-05 0:12
    pjnaughter14-Jul-05 0:12 
    QuestionHow to upload a file to a HTTP server? Pin
    MaTrIX2k216-May-04 12:32
    MaTrIX2k216-May-04 12:32 
    AnswerRe: How to upload a file to a HTTP server? Pin
    pjnaughter17-May-04 0:14
    pjnaughter17-May-04 0:14 
    Question102 error(s), 5 warning(s) What's wrong?? Pin
    Locura6668-Mar-04 16:26
    Locura6668-Mar-04 16:26 
    AnswerRe: 102 error(s), 5 warning(s) What's wrong?? Pin
    pjnaughter17-May-04 0:18
    pjnaughter17-May-04 0:18 
    QuestionHow to ignore global offline mode? Pin
    Ralfy3-Mar-04 17:25
    Ralfy3-Mar-04 17:25 
    GeneralLots and Lots of Errors when compiling Pin
    shultas11-Feb-04 17:04
    shultas11-Feb-04 17:04 
    GeneralRe: Lots and Lots of Errors when compiling Pin
    pjnaughter11-Feb-04 21:30
    pjnaughter11-Feb-04 21:30 
    GeneralRe: Lots and Lots of Errors when compiling Pin
    shultas12-Feb-04 5:46
    shultas12-Feb-04 5:46 
    Thanks for the reply.

    I did finally get the HTML help and got it to work.

    I winded up manually copying all of the resource stuff manually with a text editor.

    I have VS .NET 2003 ... I brought up the sample program, as well as my test dummy program side by side. I tried repeatedly clicking on the resource and dragging it into the other program, but I just can't "automatically" get it to go. It "appears" that it is going to let me drop it, because the arrow turns into an arrow with a box around it, but it never shows up. I've tried "copy" and "paste" as well, but no go.

    As for the library linking. In the passed three months, I have done over 200 examples and read tons of articles on this site (I've spent probably 8-10 hours every day here Big Grin | :-D ). I've read several times, and everyone had something different to say about how to add external resources for linking. Some said what you mentioned, others say it goes as an additional dependency, while others said add it into command line arguments.

    Before using this sample program, I did not ever read anywhere about adding it in as a dependency. I was trying to put it where I read in the command line argument, and error after error came up. When I brought the two projects up side by side, and went through every single option, I finally found the "right" place to put it.

    I thank you for the reply. I did get everything going finally and it works great!

    Shultas
    GeneralRe: Lots and Lots of Errors when compiling Pin
    pjnaughter12-Feb-04 6:01
    pjnaughter12-Feb-04 6:01 
    GeneralCompile shouts: unresolved symbols Pin
    HintiFlo22-Jan-04 10:27
    HintiFlo22-Jan-04 10:27 
    GeneralRe: Compile shouts: unresolved symbols Pin
    pjnaughter22-Jan-04 11:36
    pjnaughter22-Jan-04 11:36 
    GeneralRe: Compile shouts: unresolved symbols Pin
    HintiFlo22-Jan-04 22:24
    HintiFlo22-Jan-04 22:24 
    GeneralRe: Compile shouts: unresolved symbols Pin
    HintiFlo23-Jan-04 2:24
    HintiFlo23-Jan-04 2:24 
    GeneralATL downloading Pin
    Balkrishna Talele6-Jan-04 19:16
    Balkrishna Talele6-Jan-04 19:16 
    GeneralRe: ATL downloading Pin
    pjnaughter7-Jan-04 2:46
    pjnaughter7-Jan-04 2:46 
    GeneralBinary downloads Pin
    Chris Losinger14-Dec-03 16:59
    professionalChris Losinger14-Dec-03 16:59 
    GeneralRe: Binary downloads Pin
    pjnaughter14-Dec-03 22:49
    pjnaughter14-Dec-03 22:49 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.