Results 1 to 5 of 5

Thread: Font listing

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    4

    Exclamation

    Is there any easy way to bring up a window with all the fonts avilable on a computer?

  2. #2
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    258
    Hows this ?
    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%
    You need a list box
    Visual Basic 6 SP4 on win98se

    QUIT THE RAT RACE BECAUSE YOUR MESSING THE WORLD UP !!!!!

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    You can enumerate a list using font object
    Code:
    For n = 0 To Screen.FontCount - 1
    List1.AddItem Screen.Fonts(n)
    Next n
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4
    Guest
    Same goes for the Printer. Simply use kedaman's code and replace Screen with Printer.

  5. #5
    Guest
    If you want to use CommonDialog to do it:

    Code:
    Private Sub Command1_Click()
    CommonDialog1.CancelError = True
    On Error GoTo ErrHandler
    CommonDialog1.Flags = cdlCFEffects Or cdlCFBoth
    CommonDialog1.ShowFont
    Text1.Font.Name = CommonDialog1.FontName
    Text1.Font.Size = CommonDialog1.FontSize
    Text1.Font.Bold = CommonDialog1.FontBold
    Text1.Font.Italic = CommonDialog1.FontItalic
    Text1.Font.Underline = CommonDialog1.FontUnderline
    Text1.FontStrikethru = CommonDialog1.FontStrikethru
    Text1.ForeColor = CommonDialog1.Color
    Exit Sub
    ErrHandler:
    Exit Sub
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width