INF: Specifying a Dialog Box Font in the Dialog Editor

ID Number: Q66548

3.00

WINDOWS

Summary:

To specify a font for a dialog box using the Dialog Editor, from the

Edit menu, choose Styles. In this dialog, it is possible to select a

new font and/or new font size.

The values displayed in the Point Size combo box are actually logical

font sizes. To specify point sizes for the dialog box font, it is

necessary to use a text editor to change the number in the FONT

statement of the .DLG file to the desired point size.

More Information:

The Dialog Editor displays font sizes as logical sizes, not point

sizes. This can present a problem when the dialog is sized and

aligned. For example, if Helv 16 is specified in the Dialog Editor as

the new font and size, the Dialog Editor will write as the FONT

statement in the .DLG script, "FONT 16, Helv." When this dialog is

then displayed in the application, the specified size is interpreted

as a point size and not a logical size. The result is a 16-point font,

which is much larger than the font size that was displayed in the

Dialog Editor.

Because the Dialog Editor displays logical sizes, the point size

needed in the .DLG script must be calculated. The basic formula to

calculate point sizes is as follows

(Height - Internal Leading) * 72

points = ----------------------------------

LOGPIXELSY

where

Height: The height of the font, in pixels. This is the number that

the dialog editor displays for font size.

Internal leading: The space for diacritical marks. This is the

space reserved for accents, umlauts, and tildes. This value may

be obtained from the TEXTMETRIC structure.

72: This value is derived from the fact that 1 point equals 1/72 of

an inch.

LOGPIXELSY: The number of pixels that fit into a logical inch on

the display. You can obtain this value by calling

GetDeviceCaps(hDC, LOGPIXELSY). For an 8514 device, this value

is 120; for a VGA display, this value is 96.

Once the point size for the desired font has been calculated, the .DLG

file created by the Dialog Editor should be edited. The FONT statement

should be changed to reflect the desired point size. In the example

above, the FONT statement should be changed from "FONT 16, Helv" to

"FONT 8, Helv." Unfortunately, the Dialog Editor is not fully WYSIWYG.

Therefore, the size of the dialog as displayed by the Dialog Editor

and the size of the dialog as displayed by an application may still

differ slightly. The method described above should minimize this

difference.