home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form enmfntx
- Appearance = 0 'Flat
- BackColor = &H80000005&
- Caption = "Enum Font Example"
- ClientHeight = 4020
- ClientLeft = 1095
- ClientTop = 1500
- ClientWidth = 7365
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 1
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- Height = 4425
- Left = 1035
- LinkTopic = "Form1"
- ScaleHeight = 4020
- ScaleWidth = 7365
- Top = 1155
- Width = 7485
- Begin VB.CommandButton Command1
- Appearance = 0 'Flat
- BackColor = &H80000005&
- Caption = "List TrueType"
- Height = 435
- Left = 5460
- TabIndex = 3
- Top = 180
- Width = 1395
- End
- Begin VB.CommandButton CmdListArial
- Appearance = 0 'Flat
- BackColor = &H80000005&
- Caption = "List Arial"
- Height = 495
- Left = 5460
- TabIndex = 2
- Top = 1140
- Width = 1395
- End
- Begin VB.CommandButton CmdListFonts
- Appearance = 0 'Flat
- BackColor = &H80000005&
- Caption = "ListFonts"
- Height = 435
- Left = 5460
- TabIndex = 1
- Top = 660
- Width = 1395
- End
- Begin VB.ListBox List1
- Appearance = 0 'Flat
- Height = 1785
- Left = 300
- TabIndex = 0
- Top = 1800
- Width = 5595
- End
- Begin VBX.ccCallback Callback1
- IntVersion = 5
- Left = 6120
- Top = 2700
- Type = 2 'EnumFonts
- End
- Attribute VB_Name = "enmfntx"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Option Explicit
- Private Sub Callback1_EnumFonts(lpLogFont As Long, lpTextMetrics As Long, nFontType As Integer, lpData As Long, retval As Integer)
- Dim fullname$, stylename$
- ' agCopyData copies the data referenced by the pointer
- ' provided into a structure
- agCopyData ByVal lpLogFont, nlf, Len(nlf)
- agCopyData ByVal lpTextMetrics, ntm, Len(ntm)
- ' Only look at TrueType fonts.
- If lpData = 1 And nFontType <> TRUETYPE_FONTTYPE Then Exit Sub
- If nFontType = TRUETYPE_FONTTYPE Then
- fullname$ = left$(nlf.lfFullName, InStr(nlf.lfFullName, Chr$(0)))
- stylename$ = left$(nlf.lfStyle, InStr(nlf.lfStyle, Chr$(0)))
- Else
- ' Non truetype fonts do not have a valid lfFullname and lfStyle field
- fullname$ = left$(nlf.lfFaceName, InStr(nlf.lfFaceName, Chr$(0)))
- End If
- list1.AddItem fullname$ & " " & stylename$
- End Sub
- Private Sub CmdListArial_Click()
- Dim di%
- Dim fname$
- list1.Clear
- fname$ = "Arial"
- ' This gets Arial only (all styles)
- di% = EnumFontFamilies(hDC, fname$, callback1.ProcAddress, 0)
- End Sub
- Private Sub CmdListFonts_Click()
- Dim di%
- list1.Clear
- ' This gets one font for each family
- di% = EnumFontFamiliesBynum(hDC, 0, callback1.ProcAddress, 0)
- End Sub
- Private Sub Command1_Click()
- Dim di%
- list1.Clear
- ' This gets one font for each family
- di% = EnumFontFamiliesBynum(hDC, 0, callback1.ProcAddress, 1)
- End Sub
-