home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form frmEnumFonts
- BackColor = &H00C0C0C0&
- Caption = "EnumFonts"
- ClientHeight = 5775
- ClientLeft = 780
- ClientTop = 675
- ClientWidth = 6945
- Height = 6180
- Left = 720
- LinkTopic = "Form1"
- ScaleHeight = 5775
- ScaleWidth = 6945
- Top = 330
- Width = 7065
- Begin CommandButton cmdZur
- BackColor = &H00C0C0C0&
- Caption = "Zur
- Height = 330
- Left = 5775
- TabIndex = 12
- Top = 5340
- Width = 1065
- End
- Begin Frame fraComment
- BackColor = &H00C0C0C0&
- Height = 1935
- Left = 120
- TabIndex = 8
- Top = 3360
- Width = 6735
- Begin Label lblCommentText
- BackStyle = 0 'Transparent
- Caption = "Zugegeben:
- ber das SCREEN-Objekt kann man auch alle Zeichens
- tze eines Forms ermitteln. Beim Drucker m
- sste man sich aber schon der hier vorgestellten EnumFonts()-Methode bedienen. Auch wenn nur TrueType-Fonts ermittelt werden sollen m
- ssen Sie sich der Hilfe von EnumFonts() versichern. Klicken Sie in der Listbox auf einen Font um eine Kostprobe der Zeichen zu erhalten!"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 9.75
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 1635
- Left = 60
- TabIndex = 0
- Top = 360
- Width = 6615
- End
- Begin Label lblComment
- Alignment = 2 'Center
- BackColor = &H00000000&
- Caption = " Kommentar:"
- ForeColor = &H00FFFFFF&
- Height = 255
- Left = 0
- TabIndex = 1
- Top = 60
- Width = 6735
- End
- End
- Begin Frame fraDemo
- BackColor = &H00C0C0C0&
- Height = 1335
- Left = 120
- TabIndex = 5
- Top = 1980
- Width = 6735
- Begin Label lblDemoText
- Alignment = 2 'Center
- BackStyle = 0 'Transparent
- Caption = "ABCabc0123"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 13.5
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 915
- Left = 120
- TabIndex = 7
- Top = 360
- Width = 6495
- End
- Begin Label lblDemo
- Alignment = 2 'Center
- BackColor = &H00000000&
- Caption = " Demonstrations-Text:"
- ForeColor = &H00FFFFFF&
- Height = 255
- Left = 0
- TabIndex = 6
- Top = 60
- Width = 6735
- End
- End
- Begin Frame fraFonts
- BackColor = &H00C0C0C0&
- Height = 1875
- Left = 120
- TabIndex = 2
- Top = 60
- Width = 6735
- Begin SSOption optPrinter
- Caption = "PrinterFonts"
- Height = 255
- Left = 1680
- TabIndex = 11
- TabStop = 0 'False
- Top = 1560
- Width = 1455
- End
- Begin SSOption optScreen
- Caption = "ScreenFonts"
- Height = 255
- Left = 60
- TabIndex = 10
- Top = 1560
- Value = -1 'True
- Width = 1455
- End
- Begin TextBox txtHeader
- BackColor = &H00808080&
- BorderStyle = 0 'None
- Enabled = 0 'False
- ForeColor = &H00FFFFFF&
- Height = 255
- Left = 60
- MultiLine = -1 'True
- TabIndex = 9
- Top = 300
- Width = 6555
- End
- Begin ListBox lstEnumFonts
- Height = 1005
- Left = 60
- Sorted = -1 'True
- TabIndex = 3
- Top = 540
- Width = 6555
- End
- Begin Label lblFonts
- Alignment = 2 'Center
- BackColor = &H00000000&
- Caption = " Zeichensatzliste:"
- ForeColor = &H00FFFFFF&
- Height = 255
- Left = 0
- TabIndex = 4
- Top = 0
- Width = 6735
- End
- End
- Begin CBVBX CBVBX1
- CBType = 2 ' 2 - EnumFontsProc
- Left = 0
- Top = 0
- End
- Option Explicit
- Dim LogFonts(100) As LogFont
- Dim iLogFont
- Sub CBVBX1_EnumFontsProc (lpLogFont As Long, lpNewTextMetric As Long, nFontType As Integer, lpData As Long, retval As Integer)
- gt jeden aufgez
- hlten Zeichensatz in eine Listbox ein
- Dim lf As LogFont
- Dim ntm As NewTextMetric
- 'LogFont-Strutktur f
- r VB zug
- nglich machen:
- TypeAtAdress lf, ByVal lpLogFont, Len(lf)
- LogFonts(iLogFont) = lf
- 'NewTextMetric-Struktur f
- r VB zug
- nglich machen
- 'TypeAtAdress ntm, ByVal lpNewTextMetric, Len(ntm)
- lstEnumFonts.AddItem StringAtAdress(lf.lfFaceName) & Chr$(9) & lf.lfWidth & Chr$(9) & lf.lfWeight & Chr$(9) & lf.lfHeight
- lstEnumFonts.ItemData(lstEnumFonts.NewIndex) = iLogFont
- iLogFont = iLogFont + 1
- 'Der StringAtAdress Aufruf hilft, aus einem festen String die Zeichen zu extrahieren, die von einem Asc(0)-Zeichen (C-String) beendet werden
- retval = True 'Weitere Fonts aufz
- End Sub
- Sub cmdZur
- ck_Click ()
- Unload Me
- End Sub
- Sub Form_Load ()
- LoadFonts Me.hDC
- End Sub
- Sub LoadFonts (ByVal hDC%)
- Dim dummy
- Static TabStops%(10)
- iLogFont = 0
- lstEnumFonts.Clear
- TabStops(0) = 0
- TabStops(1) = 70
- TabStops(2) = 100
- TabStops(3) = 130
- TabStops(4) = 160
- TabStops(5) = 190
- dummy = SendMessage(lstEnumFonts.hWnd, LB_SETTABSTOPS, 10, TabStops(0))
- dummy = SendMessage(txtHeader.hWnd, EM_SETTABSTOPS, 10, TabStops(0))
- txtHeader.Text = "FaceName" & Chr$(9) & "Width" & Chr$(9) & "Weight" & Chr$(9) & "Height"
- dummy = EnumFonts(hDC, ByVal 0&, CBVBX1.CBAdress, 0&)
- End Sub
- Sub lstEnumFonts_Click ()
- Dim fn$
- Dim lf As LogFont
- On Error Resume Next
- If lstEnumFonts.ListIndex >= 0 Then
- lf = LogFonts(lstEnumFonts.ItemData(lstEnumFonts.ListIndex))
- fn$ = StringAtAdress(lf.lfFaceName)
- lblDemoText.FontName = fn$
- If Err Then
- MsgBox "Kann Font nicht anzeigen!"
- Exit Sub
- End If
- lblDemoText.FontSize = lf.lfHeight
- If lf.lfWeight <= 400 Then
- lblDemoText.FontBold = False
- Else
- lblDemoText.FontBold = True
- End If
- End If
- End Sub
- Sub optPrinter_Click (Value As Integer)
- If Value Then LoadFonts Printer.hDC
- End Sub
- Sub optScreen_Click (Value As Integer)
- If Value Then LoadFonts Me.hDC
- End Sub
-