GetDialogBaseUnits
The GetDialogBaseUnits
function returns the dialog box base units used by Windows to create dialog
boxes. Both Windows and applications use these units to convert the width and
height of dialog boxes and controls from dialog units, as given in dialog box
templates, to pixels, and vice versa.
LONG
GetDialogBaseUnits(VOID)
Parameters
This function
has no parameters.
Return Values
The return
value is a 32-bit value that contains the dialog base units. The low-order word
of the return value contains the horizontal dialog box base unit, and the
high-order word contains the vertical dialog box base unit.
Remarks
The
horizontal base unit is equal to the average width, in pixels, of the
characters in the system font; the vertical base unit is equal to the height,
in pixels, of the font. Furthermore, each horizontal base unit is equal to 4
horizontal dialog units; each vertical base unit is equal to 8 vertical dialog
units. Therefore, to convert dialog units to pixels, an application applies the
following formulas:
pixelX = (dialogunitX * baseunitX) / 4
pixelY = (dialogunitY * baseunitY) / 8
Similarly, to
convert from pixels to dialog units, an application applies the following
formulas:
dialogunitX = (pixelX * 4) / baseunitX
dialogunitY = (pixelY * 8) / baseunitY
The
multiplication is performed before the division to avoid rounding problems if
base units are not divisible by 4 or 8.
See Also