Microsoft KB Archive/128648

= How to Create a List Box That Lists Available Fonts =

Article ID: 128648

Article Last Modified on 2/12/2000

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition

-



This article was previously published under Q128648



SUMMARY
To create a list box that lists available system fonts in Visual FoxPro 3.0, you need to use the AFONT function. This function places information about available fonts into an array. This array may then be used to populate a list box on a form.



Step-by-Step Procedure
The following procedure demonstrates how to create a form that contains a list box that displays the available system fonts:  Open or switch to Microsoft Visual FoxPro version 3.0 and choose the New command from the File Menu. This will open the New dialog box. Select the Program radio button. Then choose the New File button. This will open an empty Program Window.  Enter the following code into the Program Window: PUBLIC X  X=CREATEOBJECT("myform") X.SHOW

** Class Definition for the FORM object ** DEFINE CLASS myform AS FORM

SCALEMODE = 0 TOP = 5 LEFT = 5 HEIGHT = 10 WIDTH = 40 ** Adding the COMBOBOX object into the form ** ADD OBJECT mycombo AS Fontcombo

ENDDEFINE

** Class Definition for the COMBOBOX object ** DEFINE CLASS FontCombo AS ComboBox

DIMENSION aFonts[1] aFonts = "" TOP = 2 LEFT = 5 HEIGHT=1.5 WIDTH=30 STYLE=2

** Init Method ** PROCEDURE Init

=AFONT(THIS.aFonts) THIS.RowSourceType=5 THIS.RowSource="THIS.aFonts" THIS.Value=THISFORM.FontName

ENDPROC

ENDDEFINE  Choose the Do Program command from the Program Menu, and save the file when prompted. A form will now appear that contains a list box that displays the available system fonts.

Additional query words: VFoxWin listbox

Keywords: kbcode KB128648

-

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

© Microsoft Corporation. All rights reserved.