Freigeben über


Extending Forms

Page frames make it possible for you to extend the surface area of your forms, and ActiveX controls make it possible for you to extend the functionality of your forms.

Using Page Frames

A page frame is a container object that contains pages. Pages in turn contain controls. Properties can be set at the page frame, page, or control level.

To see examples of using page frames

  1. Run Solution.app in the Visual FoxPro \Samples\Solution directory.
  2. In the tree view, click Controls, and then click Page frame.

You can think of the page frame as a three-dimensional container that presents layered pages. Only controls on the top page (or on top of the page frame) can be visible and active.

The page frame defines the location of the pages and the amount of the page that is visible. The upper-left corner of a page is anchored to the upper-left corner of the page frame. Controls can be placed on pages that are beyond the dimensions of the page frame. These controls are active, but are not visible unless you programmatically change the Height and Width properties of the page frame to make the controls visible.

Using Pages in an Application

With page frames and pages, you can create tabbed forms or dialog boxes with the same kind of interface capabilities that you see in the Project Manager.

In addition, page frames make it possible for you to define a region of the form where you can easily swap controls in and out. For example, in Wizards, most of the form remains constant, but an area of the form changes with each step. Instead of creating five forms for the wizard steps, you could create one form with a page frame and five pages.

Solution.app, in the Visual FoxPro ...\Samples\Solution directory, contains two page frame examples that demonstrate using frames with and without tabs.

Adding Page Frames to a Form

You can include one or more page frames on any form.

To add a page frame to a form

  1. In the Form Controls toolbar, choose the Page Frame button and drag to size in the Form window.

  2. Set the PageCount property to indicate the number of pages to include in the frame.

  3. From the frame's shortcut menu, choose Edit to activate the frame as a container. The page frame border widens to indicate that it is active.

  4. Add controls the same way you would add them to a form.

    Note   Like other container controls, you must select the page frame and choose Edit from the right mouse menu, or select the container in the Object drop-down list in the Properties window, so that the container is selected (has a wider border) before you add controls to the page you are designing. If you do not activate the page as a container before adding controls, the controls will be added to the form instead of the page, even though they might appear to be on the page.

To select a different page in the page frame

  1. Activate the page frame as a container by right-clicking it and choosing Edit.

  2. Select the tab of the page you want to use.

    -or-

Adding Controls to a Page

When you add controls to a page, they are visible and active only when their page is active.

To add controls to a page

  1. In the Object box of the Properties window, select the page. A border appears around the page frame indicating that you can manipulate contained objects.
  2. In the Form Controls toolbar, choose the control button you want and drag to size in the page.

Managing Long Captions on Page Tabs

If the captions on your tabs are longer than can be displayed on the tab given the width of the page frame and the number of pages, you have two options:

  • Set the TabStretch property to 1 - Single Row to show only the characters of the captions that will fit on the tabs. Single Row is the default.
  • Set the TabStretch property to 0 - Multiple Rows to stack the tabs so that the entire caption on all the tabs is visible.

Changing Pages Programmatically

Whether a page frame is displayed with tabs or not, you can programmatically make a page active by using the ActivePage property. For example, the following code in the Click event procedure of a command button on a form changes the active page of a frame page on the form to the third page:

THISFORM.pgfOptions.ActivePage = 3

Common Page Frame Properties

The following page frame properties are commonly set at design time.

Property Description
Tabs Whether tabs are visible for the pages.
TabStyle Whether or not the tabs are all the same size and together the same width as the page frame.
PageCount The number of pages in the page frame.

See Also

Making Controls Easier to Use | Manipulating Objects with OLE Container Control and OLE Bound Control | Using Controls | Controls and Objects