|
|
Title | Let the user select a font |
Description | This example shows how to let the user select a font in Visual Basic 6. It uses the CommonDialog control's ShowFont method to display the font dialog. |
Keywords | font, CommonDialog, ShowFont, select font |
Categories | Controls, Graphics |
|
|
This program initializes a Common Dialog control's font properties and then calls its ShowFont method.
Use the CommonDialog control's ShowFont method. If the user selects a font and clicks OK, the program makes its label control use the selected font.
|
|
Private Sub Command1_Click()
' Initialize the dialog's properties.
With dlgFont
.FontName = Label1.Font.Name
.FontSize = Label1.Font.Size
.FontBold = Label1.Font.Bold
.FontItalic = Label1.Font.Italic
.FontUnderline = Label1.Font.Underline
.FontStrikethru = Label1.Font.Strikethrough
End With
dlgFont.Flags = cdlCFScreenFonts
dlgFont.CancelError = True
On Error Resume Next
dlgFont.ShowFont
If Err = cdlCancel Then Exit Sub
' Use the dialog's properties.
With dlgFont
Label1.Font.Name = .FontName
Label1.Font.Size = .FontSize
Label1.Font.Bold = .FontBold
Label1.Font.Italic = .FontItalic
Label1.Font.Underline = .FontUnderline
Label1.Font.Strikethrough = .FontStrikethru
End With
End Sub
|
|
|
|
|
|