Forum > Networking and Web Programming

fphttpclient example downloading with progressbar on the main form.


Attached my fphttpclient example for downloading  files or webpages with a progressbar on the main form.

I could not find any example for downloading files with a progressbar except this one:,55886.msg415662.html?PHPSESSID=cq11qlk65nsrfkm6km43hdn7a5#msg415662

but in above example the download progressbar is on a new popup form. My new example allows placing the download progressbar on the main form. The data is placed in a string but it works for both text and binary files.

If OpenSSL is installed or libraries are available in your project directory then HTTPS is supported.

Tested in Windows, Linux and macOS.

Any suggestion to improve the code?


I would use either a statusbar or put it in the form's caption bar. But it is a good idea.


--- Quote from: han on May 29, 2024, 10:29:43 am ---Any suggestion to improve the code?

--- End quote ---
It looks a bit weird to me that the interface is implemented by the form. If I were you, I would just use fphttpclient in the form directly. That OnDataReceived can take a form's method instead, directly updating the progress bar in the form. Despite available, interface is not often used in Object Pascal. The event driven nature of FCL/LCL kinda makes it unnecessary, you just assign event to the corresponding handler instead.

Something as simple as the attached project.


[0] Message Index

Go to full version