RAD Studio |  |

Building a VCL Forms Web Browser Application
See Also
Collapse All

Creating the Web browser application consists of the following steps:

1. Create a VCL Form with a button control.
2. Add a TWebBrowser component to the form.
3. Add controls to enter a URL and launch the browser.
4. Write the code to launch the browser when a button is clicked.
5. Run the application.

To create a VCL Form

1. Choose FileNewOtherDelphi Projects or C++Builder Projects and double-click the VCL Forms Application icon. The VCL Forms Designer is displayed.
2. From the Internet page of the Tool Palette, place a TWebBrowser component on the form.
3. With the TWebBrowser component selected on the form, drag the handles to adjust the size of the browser window. Leave some space on the form above the TWebBrowser to add a URL entry window. If the window is not large enough to display a browser page in its entirety, the TWebBrowser component adds scrollbars when you run the application and launch the browser window.
4. From the Standard page of the Tool Palette, place a TMemo component on the form. With the TMemo component selected on the form, drag the handles to adjust the size to accommodate a user-entered URL.
5. From the Standard page of the Tool Palette, place a Label component on the form.
6. Select the Label, and in the Object Inspector, enter URL: as the Label caption.
7. From the Standard page of the Tool Palette, place a TButton component on the form.
8. Select the Button, and in the Object Inspector, enter OK as the TButton caption.

To code a button click event that launches the browser

1. Select Button1 on the form.
2. In the Object Inspector, double-click the OnClick action on the Events tab. The Code Editor displays, with the cursor in the Button1Click event handler block.
3. Type the following code:

Copy Code

    WebBrowser1.Navigate(WideString(Memo1.Text));

Copy Code

    WebBrowser1–>Navigate( WideString( Memo1–>Text ) );

To run the application

1. Choose RunRun to build and run the application.
2. Enter a URL to a Web page in the memo window; then click the button. The browser launches in the TWebBrowser window.

See Also

VCL Overview

Building a VCL Forms Application

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!