How to Change the Font in All Controls Without Using a Builder

This article was previously published under Q137945
This article has been archived. It is offered "as is" and will no longer be updated.
The Visual FoxPro Form Designer does not provide a menu choice to selectall objects and change the font. This capability was available in FoxProversion 2.x for Windows.

You can create a builder that will change the font for all selectedobjects. This article shows you how to do the same thing without writingbuilder code by:
  • Using the Command window. -or-

  • Using the ASELOBJ() function in a program.

Using the Command Window Only

To change the font for all objects on a form, perform the following steps:
  1. Design the form.
  2. Click the exclamation mark (!) icon on the toolbar to run the form.
  3. Switch to the Command window.
  4. Change the font of all objects in the running form by using the setall method of the form. Enter the following command in the Command window, where formname is the name of your form:
       formname.setall("FontName","Arial")   formname.setall("FontSize",10)						
  5. Save the form back to a .scx file format by using the saveas method of the form:
This method does have some limitations:
  • All objects on the form are changed to the same font. You can use the optional third parameter of the setall method to limit the change to certain types of objects.
  • The saveas method does not allow the form to be saved under the original filename.
  • If you want to change the font of selected objects only, you must write a builder or set the properties for each individual object separately.
  • Objects added after doing this procedure do not reflect the new font setting.

Using the ASELOBJ() Function in a Program

The following program can form the basis of a builder. You can also runthis program from the Command window while in design mode of a form.
  1. Design the form, and select the objects.
  2. Create a .prg file that contains the following lines of code, and save the program as Myfonts.prg:
       lnNumOfControls = ASELOBJ(laFonts)   FOR ctr = 1 TO lnNumOfControls      WITH laFonts(ctr)         .FontName = "Arial"         .FontSize = 12         .FontBold = .F.      ENDWIDTH   ENDFOR						
  3. In the Command window, type this command:
       DO myfonts						
This technique has the advantage of making changes directly in the form.

Article ID: 137945 - Last Review: 02/24/2014 08:22:35 - Revision: 1.1

  • Microsoft Visual FoxPro 3.0 Standard Edition
  • kbnosurvey kbarchive KB137945