How to Create a Screen Programatically

Last reviewed: April 30, 1996
Article ID: Q128769
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, version 3.0

SUMMARY

In FoxPro version 2.x for Windows the syntax for creating a QUICK SCREEN is CREATE SCREEN <screen name> FROM <table name>. However, this command is not supported in Visual FoxPro version 3.0. You can, however, use a program to create a QUICK FORM in Visual FoxPro by using the code listed in this artcle.

MORE INFORMATION

Code Sample

******************************************************************* * The following code programatically creates a Visual FoxPro * form and adds Textbox objects it. Each Textbox object has as * its ControlSource and Name the name of a corresponding field from * the customer database that ships with Visual FoxPro. * * The Textbox objects use the Courier New, Size 8 regular font for * simple calculations in the placement of each object. * * The new form is saved in the same directory as the selected table. ******************************************************************** USE C:\VFP\SAMPLES\DATA\CUSTOMER.DBF IN 0 SELECT customer

=AFIELDS(mafield) count = ALEN(mafield,1)

myForm = CREATEOBJECT('FORM') myform.SCALEMODE=0

FOR i = 1 TO count STEP 1

   STORE ALIAS()+'.'+mafield[i,1] TO mcontrol
   myForm.ADDOBJECT(mafield[i,1],'Textbox')
   WITH myForm.&mafield[i,1].
     .CONTROLSOURCE = mcontrol
     .FONTNAME = 'Courier New'
     .FONTSIZE = 8
     .FONTBOLD = .F.
     .HEIGHT = 1.25
     .TOP = (i-1) + .25
   ENDWITH
ENDFOR

myForm.SAVEAS(STRTRAN(DBF(ALIAS()),'DBF','SCX'))

FLUSH

MODIFY FORM (STRTRAN(DBF(ALIAS()),'DBF','SCX')) NOWAIT SAVE

CLEAR ALL RELEASE ALL

* END.

You can also use the FORM WIZARD to create a new form if you are not using a Runtime version of Visual FoxPro. To call the FORM WIZARD use this syntax:

   DO (_wizard) WITH 'autoform'


Additional reference words: 3.00 VFoxWin
KBCategory: kbprg kbcode
KBSubcategory: FxprgGeneral


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 30, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.