BCX_FONTDLG function

Purpose: BCX_FONTDLG function creates a Font dialog box in which attributes for a logical font can be chosen. These attributes include a typeface name, style (bold, italic, or regular), point size, effects (underline, strikeout, and text color), and a script(or character set).


 Syntax:

 RetVal% = BCX_FONTDLG(UseLast, hWnd)

 Parameters:

  • RetVal% The return value is nonzero if the user clicks the OK button of the dialog box, The CHOOSEFONT structure members indicate the user's selections.

    The return value is zero if the user cancels or closes the Font dialog box or if an error occurs. Call the CommDlgExtendedError function to get EXTENDED ERROR information. CommDlgExtendedError can return one of the following values:

    • CDERR_FINDRESFAILURE CDERR_NOHINSTANCE
    • CDERR_INITIALIZATION CDERR_NOHOOK
    • CDERR_LOCKRESFAILURE CDERR_NOTEMPLATE
    • CDERR_LOADRESFAILURE CDERR_STRUCTSIZE
    • CDERR_LOADSTRFAILURE CFERR_MAXLESSTHANMIN
    • CDERR_MEMALLOCFAILURE CFERR_NOFONTS
  • UseLast [OPTIONAL] TRUE or FALSE, the default argument of this parameter is set to FALSE. If the argument is set as TRUE, the dialog values will default to those which were selected the last time the BCX_FONTDLG function was called. These values also can be changed by setting the elements of the BCX declared variable BCX_FONT. See below for BCX_FONT details.
  • hWnd [OPTIONAL] If a window handle is specified, the dialog will be set as MODAL.

BCX_FONTDLG also creates a BCX_FONT structure populated with the following members with values derived from the choices made in the font dialog box.

See below for an example of how to retrieve these values.

Example:


 DIM RetVal%

 RetVal% = BCX_FONTDLG      ' Fill the BCX_FONT structure
 PRINT "BCX_Font.Name$     = ", BCX_Font.Name$     ' Font Name
 PRINT "BCX_Font.Size      =" , BCX_Font.Size      ' Font Point Size
 PRINT "BCX_Font.Italic    =" , BCX_Font.Italic    ' Boolean(0 or 1)
 PRINT "BCX_Font.Bold      =" , BCX_Font.Bold      ' Boolean(0 or 1)
 PRINT "BCX_Font.Underline =" , BCX_Font.Underline ' Boolean(0 or 1)
 PRINT "BCX_Font.Strikeout =" , BCX_Font.Strikeout ' Boolean(0 or 1)
 PRINT "BCX_Font.Rgb       =" , BCX_Font.Rgb       ' RGB font color

FontDialogDemo.bas   is a complete program demonstrating the use of the BCX_FONTDLG function.