Share via


Creating an Active Document

A Visual FoxPro Active Document is an application (.app) created from a Visual FoxPro project. Earlier versions of Visual FoxPro made it possible for you to create applications, so you may already be familiar with creating applications. For more information about creating applications, see Compiling an Application.

Any application can be run in Internet Explorer. However, only applications based on the ActiveDoc base class, described below, support the properties, events, and methods that provide communication with the Active Document host. Visual FoxPro Active Documents are easy to create.

The ActiveDoc Base Class

The "main file" for an Active Document must be set to a class based on the ActiveDoc base class. Other types of applications require that the main file be a program or a form.

The ActiveDoc base class, created with the Class Designer, provides properties, events, and methods for an Active Document, and provides communication with the Active Document host. For example, the ContainerRelease event occurs when an Active Document is released by its host. You can place code in the ContainerRelease event to close files, complete transactions, and perform other clean up duties before the Active Document is released.

To set the main file to a class based on the ActiveDoc base class

  1. Add the visual class library (.vcx) containing the class based on the ActiveDoc base class to the project.
  2. Expand the visual class library (.vcx) hierarchy by clicking the plus (+) box to the left of the library name, or right-click the library and choose Expand All from the shortcut menu.
  3. Right-click the Active Doc class and choose Set Main from the shortcut menu.

The ActiveDoc Object

When you open a Visual FoxPro Active Document in Internet Explorer, an ActiveDoc object is created from the ActiveDoc base class. The ActiveDoc object responds to events and method calls for the ActiveDoc base class.

ActiveDoc Object Properties, Events, and Methods

The following tables list the properties, events, and methods supported by the ActiveDoc object.

Properties

BaseClass Caption Class
ClassLibrary Comment ContainerReleaseType
Name Parent ParentClass
Tag    

Events

CommandTargetExec CommandTargetQuery ContainerRelease
Destroy Error HideDoc
Init Run ShowDoc

Methods

AddProperty ReadExpression ReadMethod
ResetToDefault SaveAsClass WriteExpression

Active Document Event Sequences

When an Active Document application is opened in Internet Explorer, the Active Document runs and the Active Document Init event occurs, followed by the ShowDoc event. When Internet Explorer successfully hosts the Active Document, the Active Document Run event occurs. In general, you should see the Active Document program code in this event. Typically, the Run event contains code that executes your menu code, executes the main form in the application, and contains READ EVENTS to start event processing, just like a standard Visual FoxPro application.

You can put setup code in your Active Document Init event, but if the code takes too long to execute, the Active Document container might generate a time out error. If you do put setup code in the Init event, it should not require user interaction or create a user interface.

The HideDoc event occurs if you navigate from an Active Document, and the ShowDoc event occurs when you navigate back to the Active Document.

If Internet Explorer closes while the Active Document is hosted, the HideDoc event occurs, then the ContainerRelease Event occurs. The ContainerRelease event also occurs if the Active Document falls out of the Internet Explorer 3.0 cache.

When the ContainerRelease event occurs, the program code in the event can do the following:

  • Close files, clean up after itself, and issue QUIT to close the Active Document.

  • Set the ContainerReleaseType property to 0 (the default), which opens the Active Document in the Visual FoxPro run time. The Active Document continues to run in the main Visual FoxPro window of the run time.

    **Note   **The CommandTargetExec event occurs if Internet Explorer 4.0 is about to close the Active Document or navigate from the Active Document. In these cases, the CommandTargetExec event nCommandID parameter is set to 37, and you can set the eArgOut parameter to false (.F.) to prevent the Active Document from being closed by Internet Explorer. Internet Explorer 3.0 doesn't support the CommandTargetExec event.

New Active Document Functions

Two new Visual FoxPro functions, GETHOST( ) and ISHOSTED( ), provide information about an Active Document host. GETHOST( ) returns an object reference to an Active Document host. ISHOSTED( ) returns a logical value indicating whether an Active Document is hosted.

See Also

Active Documents | Forms in Active Documents | Interoperability and the Internet | Compiling an Application | Menus in Active Documents | Running Active Documents