Visit our Sponsor   Visit our Sponsor
delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback



Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi








Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (1)


How to write your own progressbar in less than 2 minutes...Component available for this articleFormat this article printer-friendly!Bookmark function is only available for registered users!
Product:
Delphi 7.x (or higher)
Category:
Component Writing
Skill Level:
Scoring:
Last Update:
11/17/2008
Search Keys:
delphi delphi3000 article borland vcl code-snippet web browser adding progress bar web browser with progress bar
Times Scored:
1
Visits:
2807
Uploader: Frank de Hell
Company:
Reference: http://www.superliegebeest.nl/delphi.php#2
Component Download: http://www.superliegebeest.nl/d7/epwg.zip
 
Question/Problem/Abstract:
This very short tutorial shows you how to add a progress bar to any web browser programs you make in less than 2 minutes. It is very basic, and kept as short as possible, you can figure out most of the code just by looking at it. Aimed at beginners, this gives you an easy and quick way to have a working progress bar which informs the user of the progress the web browser is making! You can then focus on the other tasks like for instance the graphical representation to make it the way you want it. Included is the completed example. I hope this little bit of conceptual knowledge will help you
Answer:




How to build a webbrowser with a progressbar in 2 minutes!


1. Start a new project



2. Drop a TWebBrowser component 



3. Drop a TEdit component

In the object inspector change its Text property in: 

http://www.google.com 




4. Drop a TButton component, doubleclick it and add:

FDownCount:=0;

WebBrowser1.Navigate(Edit1.Text);




5. Drop a TProgressBar




6. In the private section add:

FDownCount: Integer;




7. Select the Webbrowser component, and go to the property inspector

and click the tab Events:


Doubleclick OnDownloadBegin [in the dropdownbox] add:

Inc(FDownCount);

ProgressBar1.Position:=0;



Doubleclick OnDownloadComplete [in the dropdownbox] add:

Dec(FDownCount);

ProgressBar1.Position:=0;



Doubleclick OnProgressChange [in the dropdownbox] add:

if (ProgressMax  0) and (Progress  0) and (FDownCount  0) then

begin

ProgressBar1.Position:=Trunc(Progress / ProgressMax) * 100;

ProgressBar1.Update;

Sleep(100);

Application.ProcessMessages;

end;



8. You are finished now!


For your reference see the below Unit1.pas after it is finished: 

/////////////////////////////////////////////////////////////////////

unit Unit1;

/////////////////////////////////////////////////////////////////////

interface

/////////////////////////////////////////////////////////////////////

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, ComCtrls, StdCtrls, OleCtrls, SHDocVw;

/////////////////////////////////////////////////////////////////////

type

TForm1 = class(TForm)

Edit1: TEdit;

ProgressBar1: TProgressBar;

Button1: TButton;

WebBrowser1: TWebBrowser;

procedure Button1Click(Sender: TObject);

procedure Webbrowser1DownloadBegin(Sender: TObject);

procedure Webbrowser1DownloadComplete(Sender: TObject);

procedure Webbrowser1ProgressChange(Sender: TObject; Progress, 

ProgressMax: Integer);

private

FDownCount: Integer;

public

{ Public declarations }

end;

/////////////////////////////////////////////////////////////////////

var

Form1: TForm1;

/////////////////////////////////////////////////////////////////////

implementation


{$R *.dfm}

/////////////////////////////////////////////////////////////////////

procedure TForm1.Button1Click(Sender: TObject);

begin

FDownCount:=0;

WebBrowser1.Navigate(Edit1.Text);

end;

/////////////////////////////////////////////////////////////////////

procedure TForm1.Webbrowser1DownloadBegin(Sender: TObject);

begin

Inc(FDownCount);

ProgressBar1.Position:=0;

end;

/////////////////////////////////////////////////////////////////////

procedure TForm1.Webbrowser1DownloadComplete(Sender: TObject);

begin

Dec(FDownCount);

ProgressBar1.Position:=0;

end;

/////////////////////////////////////////////////////////////////////

procedure TForm1.Webbrowser1ProgressChange(Sender: TObject; Progress, 

ProgressMax: Integer);

begin

if (ProgressMax  0) and (Progress  0) and (FDownCount  0) then

begin

ProgressBar1.Position:=Trunc(Progress / ProgressMax) * 100;

ProgressBar1.Update;

Sleep(100);

Application.ProcessMessages;

end;

end;

/////////////////////////////////////////////////////////////////////

end.

/////////////////////////////////////////////////////////////////////



Easy Progress Bar Writing Guide by Nullified 






Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment
No response anymore?
    Nullified van Bommel (Jul 28 2010 3:10PM)

This is my own article, i created it years ago, but forgot the password, and now i do not get any reply anymore, while my previous domain had been shutdown, use the new url please

http://www.delphi7.nl/tutorials/progressbar.php
Respond














 
Sign up to consume product discounts for Bronze memberships !

read more


  Visit our Sponsor

 

  Community Ad of
Hans Gulö
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)