Friday, October 13, 2017

Web browser Delphi Example (Tip for 10 )


As you will see, it is possible to create simple Web browser very quickly using Delphi and component TWebBrowser , which encapsulates Internet Explorer ActiveX component.

In this video you can see all the details of creating such web browser :

And of course following is the source code for this example :




(code style formatted by http://hilite.me/ )


unit MainForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, OleCtrls, SHDocVw, StdCtrls, ExtCtrls;

type
  TfrmMain = class(TForm)
    txtAddress: TEdit;
    cmdLoad: TButton;
    WebBrowser1: TWebBrowser;
    Panel1: TPanel;
    cmdBack: TButton;
    procedure FormCreate(Sender: TObject);
    procedure cmdLoadClick(Sender: TObject);
    procedure cmdBackClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 // Simple example which can be built to be a real web browser.
var
  frmMain: TfrmMain;

implementation

{$R *.dfm}

procedure TfrmMain.cmdBackClick(Sender: TObject);
begin
WebBrowser1.GoBack;   //it seams that something is not working :-)
//a lot of options available to expand app
end;

procedure TfrmMain.cmdLoadClick(Sender: TObject);
begin
WebBrowser1.Navigate(txtAddress.Text);
end;

procedure TfrmMain.FormCreate(Sender: TObject);
begin
WebBrowser1.Silent:=True; //disable java script errors/windows...
end;

end.

2 comments:

Popular Posts

Recent Posts

Unordered List

Text Widget

Pages

Search This Blog

Powered by Blogger.

Contributors

Text Widget