Private Sub Form_Load()
Dim new_font As Long
Dim old_font As Long
Dim txt As String
Dim text_metrics As TEXTMETRIC
Dim face_name As String
Dim face_len As Long
' Load the system font into the form.
new_font = GetStockObject(SYSTEM_FONT)
old_font = SelectObject(hdc, new_font)
' Get the font's name.
face_name = Space$(256)
face_len = GetTextFace(hdc, Len(face_name), face_name)
face_name = Left$(face_name, face_len)
lblFaceName.Caption = face_name
' Get the font's metrics.
GetTextMetrics hdc, text_metrics
txt = ""
If text_metrics.tmWeight >= 700 Then txt = txt & "bold "
If text_metrics.tmItalic Then txt = txt & "italic "
If text_metrics.tmUnderlined Then txt = txt & _
"underlined "
If text_metrics.tmStruckOut Then txt = txt & _
"strikethrough "
lblFontDescr.Caption = txt
' Display a sample in this font.
CurrentX = 60
CurrentY = lblFontDescr.Top + lblFontDescr.Height + 120
Print "This text was drawn in the system font"
' Reselect the form's original font.
SelectObject hdc, old_font
' Display a sample in the original font.
CurrentX = 60
Print "This text was drawn in the form's original font"
End Sub
|