Total Visual SourceBook

Total Visual SourceBook CD and Printed Manual

Microsoft Access/ Office 2016, 2013, 2010, and 2007 Version
is Shipping!

New features in Total Visual SourceBook for Access, Office 2007 and VB6

Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!

Separate version for Access/Office 2003, 2002, and 2000.

Separate version for:
Access 97/95


View all FMS products for Microsoft AccessAll Our Microsoft Access Products

SourceBook Info:

Why SourceBook?

 

"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."

Van T. Dinh, Microsoft MVP

 

 

 

Microsoft Access, Office/VBA, VB6 Modules royalty-free source code libraryMicrosoft Access Modules royalty-free source code libraryMicrosoft Access VBA and VB6 Module Library Free trial of Total Visual SourceBook for Microsoft Access, Office, VB6 and VBA

Class: FontDialog in Category Windows : Common Dialogs from Total Visual SourceBook

Displaying the Font Common Dialog without using the Microsoft Common Dialog Control in VB6 and VBA with support for 32 and 64 bit API calls.

Procedure List

Procedure Name

Type

Description

(Declarations) Declarations Declarations and private variables for the CFontDialog class
Color Property Get the font color
Flags Property Set the flags for the dialog.
Font Property Get a Font object representing the selections made in the Font dialog. You must use the FonInitToLogFontStruct flag for these settings to work. This property should be used with the Set syntax. For example: Set FontDialog.Font = mFont
FontType Property Get the font type.
Max Property Get the current maximum font size.
Min Property Get the current minimum font size.
Style Property Get the current font style. If the FonUseStyle flags is specified, the style combo is initialized to the value of this property. When the dialog closes, this property contains the user's selection.
Class_Initialize Initialize Set initial values
Show Method Display the Windows font common dialog.
HeightToPoints Private Convert a font height to a font point size. The font height is measured in logical device units. Most windows API functions for dealing with fonts require the font height in logical units. This function only works correctly in the MM_TEXT mapping mode.
PointsToHeight Private Convert a font point size to a font height (in pixels). The font height is measured in logical device units. Most windows API functions for dealing with fonts require the font height in logical units. This function only works correctly in the MM_TEXT mapping mode.

Example Code for Using Class: FontDialog

' Example of CFontDialog
'
' To try this example, do the following:
' 1. Create a new form
' 2. Add a command button named 'cmdTest'
' 3. Add a text box named 'txtTest'
' 4. Paste all the code from this example to the new form's module.
' 5. Run the form

Private Sub cmdTest_Click()
  ' Comments: Example of using the CFontDialog class to select a font, then show the results on the form's text box

  Dim clsFontDialog As CFontDialog

  ' Initialize the class
  Set clsFontDialog = New CFontDialog

  With clsFontDialog

    ' Set the style for the font dialog
    .Flags = FonBoth Or FonEffects Or FonInitToLogFontStruct

    ' Preload the settings from an existing font
    .Font.name = txtTest.FontName
    .Font.Bold = txtTest.FontBold
    .Font.Italic = txtTest.FontItalic
    .Font.Size = txtTest.FontSize
    .Font.Underline = txtTest.FontUnderline
    .Color = txtTest.ForeColor

    ' Display the dialog. If a value was chosen, update the text box with the chosen values
    If .Show() Then
      If IsNull(txtTest) Then
        ' Put a value in the text box if it's empty so you can see the font settings
        txtTest = "Sample"
      End If
      txtTest.FontName = .Font.name
      txtTest.FontBold = .Font.Bold
      txtTest.FontItalic = .Font.Italic
      txtTest.FontSize = .Font.Size
      txtTest.FontUnderline = .Font.Underline
      txtTest.ForeColor = .Color
    Else
      MsgBox "User chose cancel"
    End If

  End With

  ' Clean up and close the class
  Set clsFontDialog = Nothing

End Sub

Microsoft Access Module LibraryOverview of Total Visual SourceBook

The source code in Total Visual SourceBook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.

Additional Resources