Link to home
Start Free TrialLog in
Avatar of chazzzm
chazzzm

asked on

Adding a Font menu to a Visual Basic 6 Project

I'm sure this must be a simple thing to do, but I can find nothing anywhere on how to do it! I have a project written in Visual Basic 6. I need to add a Font menu to it so that the user can select a font which will be used for subsequent text drawing into a PictureBox. Ideally the Font Menu should list every available font on the computer (just like in Microsoft Word, for example). I assume that I would need to add a "Font" menu to the form using the Menu Editor, that the code to "populate" the "Font" menu would be part of the "Form Load" code, and that I might also need to dispose of the memory used when the form is unloaded and the application is quit. Can anyone help please?
ASKER CERTIFIED SOLUTION
Avatar of sakuya_su
sakuya_su

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GrahamSkan
Use the CommonDialog control. This demonstrates how:

Private Sub Command1_Click()
    With CommonDialog1
        .FontName = Text1.Font.Name
        .FontSize = Text1.Font.Size
        .FontBold = Text1.Font.Bold
        .FontItalic = Text1.Font.Italic
        .FontUnderline = Text1.Font.Underline
        .FontStrikethru = Text1.Font.Strikethrough
    End With

    CommonDialog1.Flags = cdlCFScreenFonts
    CommonDialog1.CancelError = True
    On Error Resume Next
    CommonDialog1.ShowFont
    If Err = cdlCancel Then Exit Sub

    ' Use the dialog's properties.
    With CommonDialog1
        Text1.Font.Name = .FontName
        Text1.Font.Size = .FontSize
        Text1.Font.Bold = .FontBold
        Text1.Font.Italic = .FontItalic
        Text1.Font.Underline = .FontUnderline
        Text1.Font.Strikethrough = .FontStrikethru
    End With
End Sub
Avatar of kaliyugkaarjun
kaliyugkaarjun

http://goforit.unk.edu/vb6/pt7_3.htm

in that read "3.5 Change Font Dialog"
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial