ChooseFont Method (FONT)


9.0F, PLBCMP GUI Only

 

The ChooseFont method activates a Windows Font Dialog that allows a user to select a font for use in a program. The method uses the following format:

 

[label]

{object}.ChooseFont

[[GIVING {return}][USING:

[*Flags=]{flags}][:

[*HDC=]{hdc}][:

[*SIZEMIN=]{min}][:

[*SIZEMAX=]{max}][:

[*COLOR=]{color}][:

[*Hwnd=]{hwnd}]]]]

 

Where:

label

Optional. A Program Execution Label.

object

Required. A WINDOW object that is accessed.

return

Optional. A Numeric Variable that receives zero if the font was selected without error. A non-zero value is returned when an error occurs for the font selection.

flags

Optional. A Numeric Variable or decimal number that specifies a bit map value for state flags that can be applied to control some aspects of the Font Dialog.

hdc

Optional. A Numeric Variable or decimal number that specifies a Windows handle for a printer device context as returned using the GETFILE HDC keyword instruction.

min

Optional. A Numeric Variable or decimal number that specifies the minimum font size presented in the font dialog.

max

Optional. A Numeric Variable or decimal number that specifies the maximum font size presented in the font dialog.

color

Optional. A COLOR object that has been previously created.

hwnd

Optional. A Numeric Variable or decimal number that specifies the owning window's handle. (9.7A)

Flags Affected: OVER, ZERO

Note the following:

  1. If the value returned is zero, the ZERO condition flag is set.

  2. If the {return} variable is too small to contain the result of the method, the OVER condition flag is set.

  3. When the {return} value is returned as a non-zero value to indicate an error, the following values can be expected:

  4.  

    Value

    Meaning …

    1

    The font dialog was terminated with the CANCEL button.

    2

    The {sizemin} value is larger than the {sizemax} value.

    3

    The {hdc} value is not a printer device context handle.

    4

    Unable to create a new font from the selected font.

    5

    Unable to create/init LOGFONT using the {object} font.

 

  1. The {flags} value is a bit map that controls execution aspects for the font dialog. The bit map values are defined as follows:

  2.  

    Value

    Keyword

    Action …

    0x1

    CF_SCREENFONTS

    Causes the dialog box to list only the screen fonts supported by the system.

    0x2

    CF_PRINTERFONTS

    Causes the dialog box to list only the fonts supported by the printer associated with the device context identified by the hdc member.

    0x40

    CF_INITTOLOGFONTSTRUCT

    Specifies that ChooseFont should use the {object} current font settings to initialize the dialog box controls.

    0x100

    CF_EFFECTS

    Causes the dialog box to display the controls that allow the user to specify strikeout, underline, and text color options. The {color} object returns the color setting when the font dialog has completed.

    0x400

    CF_SCRIPTSONLY

    Specifies that ChooseFont should allow selection of fonts for all non-OEM and Symbol character sets and the ANSI character set.

    0x4000

    CF_FIXEDPITCHONLY

    Specifies that ChooseFont should select only fixed-pitch fonts.

    0x20000

    CF_SCALABLEONLY

    Specifies that ChooseFont should allow only the selection of scalable fonts. (Scalable fonts include vector fonts, scalable printer fonts, TrueType fonts, and fonts scaled by other technologies.)

    0x40000

    CF_TTONLY

    Specifies that ChooseFont should only enumerate and allow the selection of TrueType fonts.

    0x8000

    CF_NOFACESEL

    When using CF_INITTOLOGFONTSTRUCT to initialize the dialog box controls, use this flag to selectively prevent the dialog box from displaying an initial selection for the font name combo box. This is useful when there is no single font name that applies to the text selection.

    0x20000

    CF_NOSIZESEL

    When using CF_INITTOLOGFONTSTRUCT to initialize the dialog box controls, use this flag to selectively prevent the dialog box from displaying an initial selection for the font size combo box. This is useful when there is no single font size that applies to the text selection.

    0x80000000

    CF_FORCESCREENFONTOUT

    When this bit definition is set the output FONT object is always created as a screen font. ( 9.0G).

 

  1. The {hdc} parameter can only specify a valid handle for a printer device context. When the {hdc} device context is specified, the available fonts available for selection reflect those fonts for the printer device context.

  2. The {min} and {max} values allow the font size range to be restricted for the font dialog.

  3. Upon entry, {color} intializes the font dialog. Upon exit, the {color} object returns the user selected color when the CF_EFFECTS {flags} state is specified. The {color} must be created prior to its use in the ChooseFont method. If the *COLOR parameter is not used, the font dialog defaults to the RGB value for black.

  4. Upon return, {object} has been updated with the user's selections.

  5. When using the PL/B Web Server, this method is not supported.

 

 

See Also: Method Syntax, FONT

 



PL/B Language Reference