Results 1 to 7 of 7

Thread: font list

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    779

    font list

    Does anybody know where i could get a list of fonts (i.e. the fonts that come with ms word) that i can load into a combo box?

  2. #2
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357
    You mean like this?
    VB Code:
    1. Dim Counter As Long
    2.    
    3.     For Counter = 0 To Screen.FontCount - 1
    4.         Combo1.AddItem Screen.Fonts(Counter)
    5.     Next
    ~seaweed

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    779
    That works, but I was kinda hoping i could see what the fonts look like, just like in ms word.

  4. #4
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357
    Why don't you use the Common Dialog Control and use the ShowFont method?

    Or do you want to see them on the form? I don't know a way to display multiple fonts in a standard Combo box. You could do it in a RichTextBox, though
    ~seaweed

  5. #5
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357
    Here's a way to use a RichTextBox control to display the font names in their particular font. First, add a RichTextBox control to your form and make it big enough to display a long font name. Also, set the Scrollbars property to "3 - rtfBoth".
    VB Code:
    1. Private Sub Form_Load()
    2.     Dim nCounter As Integer
    3.     Dim nCurPos As Integer
    4.    
    5.     Me.Show
    6.    
    7.     With RichTextBox1
    8.         .Font.Size = 12
    9.         .Text = ""
    10.  
    11.         For nCounter = 0 To Screen.FontCount - 2
    12.             .Text = .Text & Screen.Fonts(nCounter) & vbNewLine
    13.         Next
    14.         .Text = .Text & Screen.Fonts(nCounter + 1)
    15.        
    16.         Do
    17.             .SelStart = nCurPos + 1
    18.             nCurPos = InStr(nCurPos + 1, .Text, Chr(13))
    19.            
    20.             If nCurPos > 0 Then
    21.                 .SelLength = nCurPos - .SelStart
    22.             Else
    23.                 .SelLength = Len(.Text) - .SelStart
    24.             End If
    25.            
    26.             .SelFontName = Trim(.SelText)
    27.         Loop Until nCurPos = 0
    28.  
    29.         .SelStart = 0
    30.     End With
    31. End Sub
    ~seaweed

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    779
    So there is no way i can display multiple fonts in a standard combo box? Ok, but is there a non standard combo box i could use?

  7. #7
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357
    Sure. Just search the web.

    Here's one: http://www.freevbcode.com/ShowCode.Asp?ID=2528
    ~seaweed

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