fFONTCHOOSER


Quick Data

Header file:font.h
Object name:fFONTCHOOSER
Object index:3 of 3 Objects (Others: fFONT and fFONTNAMER)

General Description

The fFONTCHOOSER is a wrapper for the Windows common dialog that handles the selection of fonts. With this dialog, you can select fonts, which could be a rather useful thing. It integrates closely with the fFONT object to enable you to choose a font and have it ready to apply instantly.

If you do not wish to include this object when you inlclude font.h, then please #define F_FONT_H_NO_FONT_DIALOG before you include font.h.


Methods


Prototype Description

void SetTTFOnly(bool Set); This function sets whether or not the dialog will only show True Type fonts. Pass TRUE to set, FALSE to unset. The default is FALSE.
void SetExtras(bool Set); This function sets whether or not the dialog will or will not show the controls that allow the user to set things like bold, italic, and strikethrough. With this style you can also set an initial text colour. This is TRUE by default.
void SetMustExist(bool Set); This function sets whether the dialog causes an error when the user tries to choose a font or style that does not exist. I am not sure what form this comes in, but I think it is just a messagebox. This is TRUE by default.
void SetFixedPitch(bool Set); This function sets whether or not the dialog only shows fonts with a fixed pitch (ie. monospace fonts, such as Courier New). This is FALSE by default.
void SetSizeLimit(bool Set, int Min, int Max); This function sets whether the size of the font is limited between a certain range. Make Set TRUE to make these restrictions apply, or FALSE to take them off. Min is the minimum font size, and Max is the maximum font size. By default these restrictions are off.
void SetPrinterFonts(bool Set, HDC, HDCDevice); This function sets whether the dialog should only show fonts for the specified device, which might typically be a printer. Pass TRUE and a printer HDC to make this apply, or FALSE and NULL to take this off. By default this is off.
void SetScreenFonts(bool Set); This function sets whether the dialog only displays fonts that can be used on a screen. It is TRUE by default.
void SetWYSIWYG(bool Set); This function sets whether the dialog should show fonts that are available on both printers and screen. WYSIWYG stands for What You See Is What You Get, and is generally pronounced wuss-e-wig. Go on, practice it now to show off later! This is FALSE by default.
void SetNoFontSelected(bool Set); This function sets whether or not no font is selected when the dialog starts. Pass TRUE to make it not select a font, and FALSE to make it select either the first font in the list or the font specified by the fFONT that you pass along.
void SetNoSizeSelected(bool Set); This function is like the above, but it applies to the size selection.
void SetNoStyleSelected(bool Set); This funtion is like the SetNoFontSelected() function two rows up, but applies to the font styles like bold, italic, and so forth.
void Colour(COLORREF Colour); This function sets the colour of the font initally. This is not stored by the fFONT object, because Windows doesn't want to know. Any font colours need to be set manually.
COLORREF Colour(void); This function gets the colour that was selected for the font inside the dialog, or, if it wasn't changed, returns the colour that you originally set.
void ClearData(void); This function clears all of the dialog font settings. Use this only when you have/want to. The settings are not restored to the default settings.
bool Execute(HWND Owner, fFONT* ApplyTo); This function actually shows the dialog and waits for the user to choose a font. It will return TRUE if the user selects a font and clicks ok, or false otherwise. You can specify an owner window (or NULL for none), and you need to specify a font to apply the results to. Afterwards you will have a font that has the styles that the user selected ready to go. You can get the selected font and properties from the font returned. The only thing that you will need to retain from the dialog is the colour of the font, if that is relevant to you.

Sample Code

The following snippet gives a basic idea of how to use this component.


//Create a font object and a dialog...
fFONT Font;
fFONTCHOOSER FontChoose;

//Just run it..
fBUTTON Button;
if (FontChoose.Execute(NULL, &Font))
   {
   //Now you can apply the font or do whatever...
   Button.SetFont(&Font);
   }

Back to indexThe FreeFoote Foundation Classes Documentation