1. Computing
Send to a Friend via Email

TWebBrowser - Delphi Usage Examples, Tips and Tricks

The TWebBrowser Delphi component provides access to the Web browser functionality from your Delphi apps (to allow you to create a customized Web browsing application or to add Internet, file and network browsing, document viewing, and data downloading capabilities to your applications). Learn how to use the web browser control in Delphi programs.

Save a web page as HTML or MHT using Delphi
Here's how to save a web page displayed inside a WebBrowser (TWebBrowser component) as a raw HTML file or into a single (MHT) file (MHTML format: web archive - single file) programmatically using Delphi.

Manipulate Web Forms using the TWebBrowser
A web form or a form on a web page allows a web page visitor to enter data that is, in most cases, sent to the server for processing. When using the web browser (TWebBrowser) Delphi control you can programmatically fill in web form fields and submit the fom - using Delphi code. Here's how.

Load HTML Directly to a TWebBrowser
Here's how to load "static" HML code from a string into a TWebBrowser.

Append HTML Directly to a WebBrowser document
Here's how to append (add) "static" HML code from a string into a TWebBrowser.

Execute the Find Dialog in a TWebBrowser
Here's how to call a stadard IE find dialog for the TWebBrowser component.

Execute the View Source dialog in a TWebBrowser
Here's how to call a standard IE View Source dialog (to examine raw HTML) for the TWebBrowser component.

Print a TWebBrowser Document / Web Page
How to print a document/page in a TWebBrowser. Also, how to call the printer setup dialog, the page setup and the print preview screen.

Database Table to HTML
How to export your data to HTML using Delphi and ADO. This is the first step in publishing your database on the Internet - see how to create a static HTML table from an ADO query.

Disable the Context Menu in a TWebBrowser
Here's the code to disable the context menu (the one a user gets when it right-clicks inside a TWebBrowser) for TWebBrowser in a Delphi application.

Capturing a Screen Shot of a TWebBrowser Content (Web Page)
Web Browser screen shot is a graphics copy of the content on the web browser control - usually a web page (document).

Open a Web Site with the Default Web Browser in a NEW window
When using ShellExecute to open a web site or a htm file with the default web browser you *don't* have the option to specify that you want to start a new instance of the browser - in general an existing window is used.

Reset the TWebBrowser Delphi control to an Empty (Blank) Page
If, for whatever the reason is, you have to clear the web browser window, "reset" it, and display an empty page, you need to navigate to a "blank" page.

Execute a JavaScript Code on a TWebBrowser Document
Here's how to execute a custom script (JavaScript or VBScript) function on a HTML document loaded in the TWebBrowser control.

Get the Url of a Hyperlink when the Mouse moves Over a TWebBrowser Doc
To get the "href" attribute (link) of an "a" tag inside a document, while the mouse hovers over a document, you need to react on the "onmousemove" event of the IHTMLDocument2.

Enable Editing of a Document in TWebBrowser
If you need to enable a user to change the contents of a document (web page) displayed by the TWebBrowser component, use the following trick...

Get the full HTML from the TWebBrowser component
When using the TWebBrowser component you might want to grab the full HTML source code from the page being displayed by the component.

Using TWebBrowser to preview (and print) Microsoft Word documents
If you decided to use (Microsoft) Word as a "printing engine" for your applications, you will probably want to have some kind of print and print preview functionality. Here's how to use the TWebBrowser control to preview and print Microsoft Word documents.

Check if a Document in a TWebBrowser is Located on a Local Drive
If you need to know the location of a document displayed in a TWebBrowser component, you need to get the Protocol property of the IHTMLLocation. Here's a function that returns true if a document in a WebBrowser is stored locally...

Locate and Highlight a String in a TWebBrowser
Here's how to search for a string in a web document (loaded in a TWebBrowser component) and highlight every occurence of it. The WBLocateHighlight locates every occurence of a string passed as a "Text" parameter in a document loaded in a TWebBrowser component passed as the "WB" parameter. The background of the located string is turned to red with the text in white

Save a Web Page as HTML or MHT
Here's how to save a web page displayed inside a WebBrowser (TWebBrowser component) as a raw HTML file or into a single (MHT) file (MHTML format: web archive - single file).

©2014 About.com. All rights reserved.