GetDialogBaseUnits

Version 3.0

Syntax

LONG GetDialogBaseUnits()

This function returns the dialog base units used by Windows when creating dialog boxes. An application should use these values to calculate the average width of characters in the system font.

This function has no parameters.

Return Value

The return value specifies the dialog base units. The high-order word contains the height in pixels of the current dialog base height unit derived from the height of the system font, and the low-order word contains the width in pixels of the current dialog base width unit derived from the width of the system font.

Comments

The values returned represent dialog base units before being scaled to actual dialog units. The actual dialog unit in the x direction is 1/4 of the width returned by GetDialogBaseUnits. The actual dialog unit in the y direction is 1/8 of the height returned by the function.

To determine the actual height and width in pixels of a control, given the height (x) and width (y) in dialog units and the return value (lDlgBaseUnits) from calling GetDialogBaseUnits, use the following formula:

(x * LOWORD(lDlgBaseUnits))/4

(y * HIWORD(lDlgBaseUnits))/8

To avoid rounding problems, perform the multiplication before the division in case the dialog base units are not evenly divisible by four.