cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Libcurl, WinApi and progress bar

From: Matthew Veenstra <matts_lists_at_tribalmedia.com>
Date: Sat, 24 Feb 2007 12:02:53 -0800

        Przemek,

I am not sure this is the best list for this. Are you in a threaded
application? It will make some of a difference. But here is some
information that may help.

In this case libcurl is in a loop until it finishes so you will send
the message PBM_SETPOS but draw will never happen. To try and force
a draw send WM_DRAW to the window. It might need to be WM_UPDATE.

Your problems are much more an issue of not understanding the Windows
API than anything to do with the libcurl API.

Hope that helps. When trying to solve a problem like this I also
find it helpful to just write the code for the UI. Make a simple
program that progresses the UI bar. Then add this to the libcurl
code. I think you will find more success this way.

Matt
tribalmedia

On Feb 24, 2007, at 10:24 AM, Borucik wrote:

> 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