Microsoft KB Archive/128769

= How to Create a Screen Programatically =

Article ID: 128769

Article Last Modified on 2/12/2000

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition

-



This article was previously published under Q128769



SUMMARY
In FoxPro version 2.x for Windows the syntax for creating a QUICK SCREEN is CREATE SCREEN FROM. 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.



Code Sample
******************************************************************* USE C:\VFP\SAMPLES\DATA\CUSTOMER.DBF IN 0 SELECT customer
 * 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.
 * The new form is saved in the same directory as the selected table.
 * The new form is saved in the same directory as the selected table.

=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.

Additional query words: VFoxWin

Keywords: kbcode KB128769

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.