home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Eagles Nest BBS 6
/
Eagles_Nest_Mac_Collection_Disc_6.TOAST
/
Windows
/
VisBasAPIex
/
VBAPIGUIDE.image
/
FONTVIEW.FRM
< prev
next >
Wrap
Text File
|
1992-12-01
|
8KB
|
237 lines
VERSION 2.00
Begin Form Form1
Caption = "Font Viewer"
Height = 4425
Left = 1035
LinkMode = 1 'Source
LinkTopic = "Form1"
ScaleHeight = 4020
ScaleWidth = 7365
Top = 1140
Width = 7485
Begin TextBox TxtWeight
Height = 315
Left = 1260
TabIndex = 8
Text = "400"
Top = 2880
Width = 1335
End
Begin CommandButton CmdShowMetrics
Caption = "ShowMetrics"
Height = 495
Left = 2820
TabIndex = 16
Top = 2760
Width = 1215
End
Begin TextBox TxtEscapement
Height = 315
Left = 1260
TabIndex = 6
Text = "0"
Top = 2520
Width = 1335
End
Begin CommandButton CmdShowFont
Caption = "ShowFont"
Height = 495
Left = 2820
TabIndex = 13
Top = 2160
Width = 1215
End
Begin TextBox TxtWidth
Height = 315
Left = 1260
TabIndex = 4
Text = "10"
Top = 2160
Width = 1335
End
Begin PictureBox PicText
Height = 1635
Left = 4200
ScaleHeight = 1605
ScaleWidth = 2865
TabIndex = 9
Top = 2100
Width = 2895
End
Begin TextBox TxtHeight
Height = 315
Left = 1260
TabIndex = 1
Text = "10"
Top = 1800
Width = 1335
End
Begin TextBox TxtSample
Height = 315
Left = 5400
TabIndex = 14
Text = "ABC"
Top = 1440
Width = 1755
End
Begin CheckBox ChkStrikeout
Caption = "StrikeOut"
Height = 375
Left = 4140
TabIndex = 12
Top = 1020
Width = 1575
End
Begin CheckBox ChkItalic
Caption = "Italic"
Height = 375
Left = 4140
TabIndex = 11
Top = 600
Width = 1575
End
Begin CheckBox ChkUnderline
Caption = "Underline"
Height = 315
Left = 4140
TabIndex = 10
Top = 240
Width = 1635
End
Begin ListBox FontList
Height = 1395
Left = 240
Sorted = -1 'True
TabIndex = 0
Top = 240
Width = 3015
End
Begin Label Label4
Alignment = 1 'Right Justify
Caption = "Weight"
Height = 315
Left = 120
TabIndex = 7
Top = 2940
Width = 1035
End
Begin Label Label3
Alignment = 1 'Right Justify
Caption = "Escapement"
Height = 315
Left = 60
TabIndex = 5
Top = 2580
Width = 1155
End
Begin Label Label2
Alignment = 1 'Right Justify
Caption = "Width"
Height = 255
Left = 540
TabIndex = 3
Top = 2220
Width = 675
End
Begin Label Label1
Alignment = 1 'Right Justify
Caption = "Height"
Height = 255
Left = 540
TabIndex = 2
Top = 1860
Width = 675
End
Begin Label Label5
Caption = "Sample Text"
Height = 255
Left = 4200
TabIndex = 15
Top = 1500
Width = 1095
End
End
' Creates a logical font based on the various control
' settings. Then displays a sample string in that font.
'
Sub CmdShowFont_Click ()
Dim lf As LOGFONT
Dim oldhdc%
Dim rc As RECT
PicText.Cls
If FontToUse% <> 0 Then di% = DeleteObject(FontToUse%)
lf.lfHeight = Val(TxtHeight.Text)
lf.lfWidth = Val(TxtWidth.Text)
lf.lfEscapement = Val(TxtEscapement.Text)
lf.lfWeight = Val(TxtWeight.Text)
If (ChkItalic.Value = 1) Then lf.lfItalic = Chr$(1)
If (ChkUnderline.Value = 1) Then lf.lfUnderline = Chr$(1)
If (ChkStrikeout.Value = 1) Then lf.lfStrikeOut = Chr$(1)
lf.lfOutPrecision = Chr$(OUT_DEFAULT_PRECIS)
lf.lfClipPrecision = Chr$(OUT_DEFAULT_PRECIS)
lf.lfQuality = Chr$(DEFAULT_QUALITY)
lf.lfPitchAndFamily = Chr$(DEFAULT_PITCH Or FF_DONTCARE)
lf.lfCharSet = Chr$(DEFAULT_CHARSET)
lf.lfFaceName = FontList.Text + Chr$(0)
FontToUse% = CreateFontIndirect(lf)
If FontToUse% = 0 Then Exit Sub
oldhdc% = SelectObject(PicText.hDC, FontToUse%)
' Get the client rectangle in order to place the
' text midway down the box
GetClientRect agGetControlHwnd(PicText), rc
di% = TextOut(PicText.hDC, 1, rc.bottom / 2, (TxtSample.Text), Len(TxtSample.Text))
di% = SelectObject(PicText.hDC, oldhdc%)
End Sub
' Display the text metrics for the physical font.
'
Sub CmdShowMetrics_Click ()
Dim tm As TEXTMETRIC
Dim r$
Dim crlf$
Dim oldfont%
Dim tbuf As String * 80
crlf$ = Chr$(13) + Chr$(10)
If FontToUse% = 0 Then
MsgBox "Font not yet selected"
Exit Sub
End If
oldfont% = SelectObject(PicText.hDC, FontToUse%)
di% = GetTextMetrics(PicText.hDC, tm)
di% = GetTextFace(PicText.hDC, 79, tbuf)
' Add to r$ only the part up to the null terminator
r$ = "Facename = " + agGetStringFromLPSTR$(tbuf) + crlf$
If (Asc(tm.tmPitchAndFamily) And TMPF_TRUETYPE) <> 0 Then r$ = r$ + "... is a TrueType font" + crlf$
If (Asc(tm.tmPitchAndFamily) And TMPF_DEVICE) <> 0 Then r$ = r$ + "... is a Device font" + crlf$
' Curiously enough, this bit is set for variable width fonts.
If (Asc(tm.tmPitchAndFamily) And TMPF_FIXED_PITCH) = 0 Then r$ = r$ + "... is a fixed pitch font" + crlf$
r$ = r$ + "Height=" + Str$(tm.tmHeight) + ", Ascent=" + Str$(tm.tmAscent) + ", Descent=" + Str$(tm.tmDescent) + crlf$
r$ = r$ + "Internal Leading=" + Str$(tm.tmInternalLeading) + ", External Leading=" + Str$(tm.tmExternalLeading) + crlf$
r$ = r$ + "Average char width=" + Str$(tm.tmAveCharWidth) + ", Max char width=" + Str$(tm.tmMaxCharWidth) + crlf$
r$ = r$ + "Weight=" + Str$(tm.tmWeight) + ", First char=" + Str$(Asc(tm.tmFirstChar)) + ", Last char=" + Str$(Asc(tm.tmLastChar)) + crlf$
MsgBox r$, 0, "Physical Font Metrics"
di% = SelectObject(PicText.hDC, oldfont%)
End Sub
' Load the font list dialog box with the available fonts
'
Sub Form_Load ()
Dim x%
Dim a$
Screen.MousePointer = 11
For x% = 1 To Screen.FontCount
a$ = Screen.Fonts(x%)
If a$ <> "" Then FontList.AddItem a$
Next x%
Screen.MousePointer = 0
End Sub
Sub Form_Unload (Cancel As Integer)
' Be sure to clean up GDI objects when leaving the program
If FontToUse% <> 0 Then di% = DeleteObject(FontToUse%)
End Sub