Microsoft KB Archive/182579

= How To Getting Started With Active Documents =

Article ID: 182579

Article Last Modified on 7/1/2004

-

APPLIES TO


 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q182579



SUMMARY
This article demonstrates how to create a simple Active Document application.



MORE INFORMATION
The "Programmer's Guide" contains good information on the background and features of Active Documents.

The Microsoft Visual FoxPro "Programmer's Guide" defines Active Documents As follows:

"... a Windows-based, non-HTML application embedded in a browser, providing a way for the functionality of that application to be accessible from within the browser interface. Visual FoxPro Active Document applications are like any other Visual FoxPro applications in that you can run forms, reports, and labels, instantiate classes, run code, and manipulate data, but they have the added advantage of being hostable in an Active Document container, such as Internet Explorer."

The following are a series of steps to get a simple Active Document application up and running in Visual FoxPro.

Steps to Create Active Document Application
 Create a new project and name it Adtest.pjx. Select the Classes tab and click the New button to add a new class. Name the new class ADTest. Make sure it is based on the ActiveDoc class, which should be the default. Store that new class in Adtest.vcx. Once the Class Designer opens, go to the Properties sheet and select the Methods tab.  In the Run Event method code, type in the following: SET TALK OFF SET STATUS BAR OFF ** DO Adtest.mpr DO FORM Adtest.scx READ EVENTS NOTE: This code sets the Visual FoxPro Status Bar off since Internet Explorer already has a status bar. You do not want to have two status bars. TALK is set off because when the status bar is off, some FoxPro commands talk to the active window instead of the status bar. The command to "DO" a menu program is commented out since this article will not cover setting up a menu in the Active Document application. Please refer to the article listed in the REFERENCES section for information on creating a sample menu program for use with this Active Document application.

Next, a form is opened before the READ EVENTS, which keeps the entire application from exiting as soon as the application starts.  In the ContainerRelease Event method code, place the CLEAR EVENTS command. Save the Run Event code, the ContainerRelease code, the ADTest class and close the Class Designer.</li> Select the ADTest class in the Project Manager, it should have a fox head to the left. From the Project menu, point to the Set Main command. The font should turn bold.</li> Select the Documents tab and create a new form in the project. Do not use the Form Wizard.</li>  In the new form, set the following properties: BorderStyle 0-No border ScrollBars  3-Both TitleBar    0-Off WindowState 2-Maximized Left        0 Top         0 The BackColor and Picture properties can also be set to any valid value. </li>  Add a command button to the form. Change the Caption property of the Command button to "Quit" and place the following two lines of code in the Click Event method: Thisform.Release CLEAR EVENTS </li> Save the form as Adtest.scx and close the Form Designer.</li> The Active Document application is now ready to be built. In the Project Manager, select the Build button and make sure Build Application is selected in the Action section of the Build Options dialog box. Save the application as Adtest.app.</li> To run the Active Document application, Adtest.app, go to the Tools menu in Visual FoxPro and point to the Run Active Document... command. In the Run Active Document dialog box select Adtest.app for the Active Document combo box. In the Hosting combo box, select In Browser.</li>  The Active Document application should have appeared in Internet Explorer. Note that selecting the Quit button leaves Internet Explorer loaded. Close Internet Explorer and run Adtest.app again. This time, close Internet Explorer with the Closebox in the upper left corner. Internet Explorer should close this time but before the form disappears, it will briefly show up in the main Visual FoxPro window. To prevent this, modify the ADTest class and change the ContainerReleaseType to: 1-Don't show the Visual FoxPro main window Rebuild the application and test it again. This time, when Internet Explorer is closed, the form from the Active Document application will not show before closing. </li></ol>

For more information on Active Documents, follow the instructions below to get into the Active Documents section of the Visual FoxPro "Programmer's Guide."

Steps to Active Documents Topic

 * 1) In the MSDN Library for Visual Studio 6.0, open the Visual FoxPro Documentation book, and go to the What's New in Visual FoxPro page. The Active Documents topic from the "Programmer's Guide" should be the second item listed.
 * 2) Click Active Documents to open the Active Documents section of Chapter 31, "Interoperability and the Internet".

There is also a good sample in the Solutions sample under the New Features for Visual FoxPro 6.0 category titled, "Create Active Documents for the Web". This can also be accessed from the MSDN Library. Select Samples, Visual FoxPro Samples, in the Visual FoxPro Documentation book instead of into Visual FoxPro Documentation.

<div class="references_section">