RectControl → Control → Object

HTMLViewer Class

Renders HTML and provides basic navigation features.

Events
CancelLoad | NewWindow
DocumentBegin | SecurityChanged
DocumentComplete | StatusChanged
DocumentProgressChanged | TitleChanged
Error |

Properties
IsAvailable

Methods
Cancel
LoadPage
LoadPage
LoadURL

# Example

To implement a simple web browser, create a window with a large HTMLViewer control. Set its LockLeft, LockTop, LockRight, and LockBottom properties so that it resizes as the user resizes the window. Use an EditField as the URL entry area and a PushButton as the browser's Go button. That is, the user clicks Go to display the URL entered into the EditField.

In this example, the HTMLViewer is named "HTML". The following code is in the Action event of the PushButton:

HTML.LoadURL EditField1.text

You can use a ProgressBar to indicate that the web page is loading. In the HTMLViewer's DocumentBegin event, initialize and show the ProgressBar with the code:

ProgressBar1.Value = 0
ProgressBar1.Visible = True

In the DocumentProgressChanged event, increment the value of the ProgressBar. This event handler is passed the value of PercentageComplete (0 to 100).

if percentageComplete = -1 then //if it cannot be determined
ProgressBar1.Maximum = 0 //display indeterminate progress
Else
ProgressBar1.Maximum = 100
End if
ProgressBar1.Value = percentageComplete

In the Document Complete event handler, hide the ProgressBar with the line:

ProgressBar1.Visible = False.

When the title of the web page has been received, you can display it in the window's Title bar using the HTMLViewer's TitleChanged event. It is passed the new title in the String parameter newTitle. Update the window title with the line:

Title=newTitle

Use a second EditField to display the status of the load process. In the HTMLViewer's StatusChanged event handler, set the value of this EditField. This event handler is passed the current status in the String parameter, NewStatus. Display this string with the following line in the StatusChanged event:

EditField2.Text=NewStatus

If a new browser window is supposed to open, you need to insert some code to handle this event. For example, the user clicks a link that is supposed to display the new page in another window. Use the NewWindow event handler to create the window. The following code assumes that the browser is contained in a window called MainWindow.

Dim w as New MainWindow
Title = "new Window" //Title property of new window
w.Show
Return w.HTML