How to create a custom webbrowser in minutes with many added features.
It took me several months to create this tutorial so I hope many people will find it useful. Every care has been taken to make this code as accurate as possible, should there still be any mistake then please let me know via this forum.
Every feature added, is a project itself, so you can download each chapter separately if only interested in one particular feature
These are all the demo's of each follow up tutorial, in the right order. So if you download the last one, it contains all the previous features. These concern the Delphi project files, units, forms, resources but not the compiled exe since of restrictions. Full source code is present of course. No restrictions apply, use it however you want, to myself it has been a great help in understanding delphi more. :cool:
There is no need to visit my site, all the files will be posted here eventually but that is going to take a while.
Attached are files necessary if you create a browser from scratch but still want to add the features described here. They are for delphi7 but work for later versions as well
Thanks fly out to many people for helping me out, too many to mention here but they are named in the source code.
This will become a lengthy thread so please be patient and do not reply yet, so that the chapters can follow up in a convenient way, thank you.
Overview of chapters
• 1. Creating a progressbar - start here
• 2. Download - create a button that enables to download current url
• 3. Copy / Paste - enable the copy paste function in your webbrowser
• 4. Find - add a windows like menu with Find button etc
• 5. Edit current page - use a checkbox to make the opened document editable
• 6. Print - add a print button, a printer setup and page setup button
• 7. List links - list and save all the valid links in the currently opened window
• 8. Are we online - checks connection to the internet and shows the result
• 9. Change color - change the color of the progressbar into virtually any color
• 10. Over Statusbar - TProgressbar over TStatusbar like in IE
• 11. MAC address - populate statusbar with MAC address
• 12. Network Group Name - retrieve Network Group Name and show it
• 13. Local IP address - display the local IP on the statusbar
• 14. Populate TPanel - fill up the last TPanel with some info
• 15. Screen capture - create screen capture of url and save it to disk
• 16. Navigation - add standard navigation and more features
01. How to create a custom 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:
4. Drop a TButton component, double click it and add:
...
procedure TForm1.Button1Click(Sender: TObject);
begin
FDownCount:=0;
Webbrowser1.Navigate(Edit1.Text);
end;
...
5. Drop a TProgressBar
6. In the private section add:
...
procedure Webbrowser1ProgressChange(Sender: TObject; Progress, ProgressMax: Integer);
procedure Button1Click(Sender: TObject);
private
FDownCount: Integer;
public
{ Public declarations }
end;
...
7. Select the Webbrowser component, and go to the property inspector and click the tab Events:
Double click OnDownloadBegin [in the dropdownbox] add:
...
procedure TForm1.Webbrowser1DownloadBegin(Sender: TObject);
begin
Inc(FDownCount);
Progressbar1.Position:=0;
end;
...
8. Double click OnDownloadComplete [in the dropdownbox] add:
...
procedure TForm1.Webbrowser1DownloadComplete(Sender: TObject);
begin
Dec(FDownCount);
Progressbar1.Position:=0;
end;
...
9. Double click OnProgressChange [in the dropdownbox] add:
...
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;
...