|
-
Sep 27th, 2000, 12:10 PM
#1
What method do you use to fill a combobox with the names of available fonts?
I really don't want to delve into the fonts directory to do something this simple, is there an API for this?
I'm making a word processor 'cos i'm bored, you can have a copy when its finished if you like.
-
Sep 27th, 2000, 12:15 PM
#2
Hyperactive Member
Code:
Private Sub Form_Load()
Dim intBuffer As Integer, strFont As String
'load printer fonts to combobox
If Dir$(App.Path & "\fonts.dat") = "" Then
'font file doesnt exist. Create it.
Open App.Path & "\fonts.dat" For Output As #1
For intBuffer% = 0 To Printer.FontCount - 1
Call cmbFonts.AddItem(Printer.Fonts(intBuffer%))
Print #1, Printer.Fonts(intBuffer%)
Next intBuffer%
Close #1
Else
'load fonts from file
Open App.Path & "\fonts.dat" For Input As #1
While Not EOF(1)
Input #1, strFont$
Call cmbFonts.AddItem(strFont$)
Wend
Close #1
End If
cmbFonts.ListIndex = 0
''cmbFonts.Sorted = True 'Alphabetize list
'set combobox to "Arial"
For intBuffer% = 0 To cmbFonts.ListCount - 1
If cmbFonts.List(intBuffer%) = "Arial" Then cmbFonts.ListIndex = intBuffer%: Exit For
Next intBuffer%
Visual Basic 6 SP4 on win98se
QUIT THE RAT RACE BECAUSE YOUR MESSING THE WORLD UP !!!!!
-
Sep 27th, 2000, 04:21 PM
#3
Try this:
Code:
Private Sub Form_Load()
For i = 0 To Screen.FontCount - 1
Combo1.AddItem (Screen.Fonts(i))
Next i
End Sub
Private Sub Combo1_Change()
text1.FontName = Combo1.Text
End Sub
Private Sub Combo1_Click()
text1.FontName = Combo1.Text
End Sub
-
Sep 27th, 2000, 06:13 PM
#4
That will only work for ScreenFonts. To add Printer fonts, replace Screen with Printer.
-
Sep 27th, 2000, 06:33 PM
#5
_______
<?>
Code:
' Use the common dialog control to display all system fonts
'
'set the flag to fonts
CommonDialog1.Flags = cdlCFScreenFonts
'show the fonts
CommonDialog1.ShowFont
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 27th, 2000, 06:46 PM
#6
Or use cdlCFBoth for both Printer and Screen fonts.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|