cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Libcurl, WinApi and progress bar

From: Borucik <borucik_at_gmail.com>
Date: Sat, 24 Feb 2007 19:24:57 +0100

Thanks for the help, I still have problems with getting winapi progress bar
to work.
Before downloading the file, I create a new progress bar:

INITCOMMONCONTROLSEX iccInit;
iccInit.dwSize = sizeof(iccInit);
iccInit.dwICC = ICC_PROGRESS_CLASS;
InitCommonControlsEx(&iccInit);
HWND hwndPB = CreateWindowEx(0, PROGRESS_CLASS, (LPSTR)NULL, WS_CHILD |
WS_VISIBLE, 10,10,600,10, hwnd, (HMENU)0, hInstance, NULL);
SendMessage(hwndPB, PBM_SETRANGE, 0, MAKELPARAM(0,100));

I have a class file_receiver, responsible for downloading the file.
Its functions are defined in a separate file, it looks like this:

#include "net_http.h"
#include "resource.h"
#include <commctrl.h>
using namespace std;

HWND hwndPB;

//(...)

int file_receiver::show_progress(HWND hwndPB, double dltotal, double dlnow,
double utotal, double ulnow){
    SendMessage(hwndPB, PBM_SETPOS, (WPARAM)(dlnow*100/dltotal), 0);
    return 0;
}

//(...)

void file_receiver::set_options(){
    //(...)
    curl_easy_setopt(context, CURLOPT_PROGRESSFUNCTION, show_progress);
    curl_easy_setopt(context, CURLOPT_PROGRESSDATA, hwndPB);
}

It downloads the file correctly, but the progress bar is empty all the time.

Thanks in advance,
Przemek
Received on 2007-02-24