A SERVICE OF

logo

The font common dialog box lets you choose a font to use in your
Using font
application, including its typeface, size, style, and so on. For example, a
common dialog
word processor might use the font common dialog box to choose the font
boxes
for a paragraph.
TChooseFontDialog::TData has several members you must initialize before
constructing the dialog box object:
__________________________________________________________________________
Table 8.4
TData
member T pe Descriptiony
Font common dialog
____________________________________________________________________
box TData data
DC HDC
A handle to the device context of the printer whose fonts you
members
want to select, if you specify CF_PRINTERFONTS in
Flags
.
Otherwise ignored.
LogFont LOGFONT
A handle to a
LOGFONT
that specifies the font’ appearance.s
When you execute the dialog box and specify the flag
CF_INITTOLOGFONTSTRUCT the dialog box appears with,
the specified font (or the closest possible match) as the
default. When the user closes the dialog box,
LogFont
is filled
with the selections the user made.
P intSize
int The point size of the selected font (in tenths of a point). On
o
input, it sets the size of the default font. On output, it returns
the size the user selected.
Color TColor
The color of the selected font, if the CF_EFFECTS flag is set.
On input, it sets the color of the default font. On output, it
holds the color the user selected.
Style
char far* Lets you specify the style of the dialog.
FontT pe WORD
A set of flags describing the styles of the selected font. Set
y
only on output.
SizeMin
int Specifies the minimum and maximum
SizeMax
int point sizes (in tenths of a point) the user can select, if the
CF_LIMITSIZE flag is set.
____________________________________________________________________
In this example, a font common dialog box is used to set the window
object’ Font member which is used elsewhere to paint text in the window.s ,
Note how a new font object is constructed, using TFont.
void
TCommDlgWnd::CmFont()
{
TChooseFontDialog::TData FontData;
FontData.DC = 0;
FontData.Flags = CF_EFFECTS | CF_FORCEFONTEXIST | CF_SCREENFONTS;
FontData.Color = Color;
FontData.Style = 0;
FontData.FontType = SCREEN_FONTTYPE;
Chapter 8, Dialog box objects
189