get_dialog_base_units


int get_dialog_base_units()

This function obtains the dialog base units of the system.

Return

int

low-order part The horizontal dialog base unit.
high-order part The vertical dialog base unit.

Notes

For dialog boxes that use the system font, the values obtained by this function may be used to convert between dialog template units (as specified in dialog box families) and pixels.

For dialog boxes that do not use the system font, the conversion from dialog template units to pixels depends upon the font being used by the dialog box.

For either type of dialog box, the function map_dialog_rectangle may be used to perform the conversion from dialog units to pixels. The function map_dialog_rectangle takes the font into account and correctly converts a rectangle from dialog template units into pixels.

The horizontal base unit returned by this function 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.

For a dialog box that does not use the system font, the base units are the average width and height (in pixels) of the characters in the dialog's font. The functions get_text_metrics and get_text_extent may also be used to calculate these values for a selected font. However, by using the function map_dialog_rectangle errors that might result if calculations are different from those performed by the system may be avoided.

Each horizontal base unit is equal to 4 horizontal dialog template units. Each vertical base unit is equal to 8 vertical dialog template units. Therefore, to convert dialog template units to pixels, the following formulae may be used.

pixelX = (dialogUnitX * baseUnitX) / 4 
pixelY = (dialogUnitY * baseUnitY) / 8 

Likewise, to convert from pixels to dialog template units the following formulae may be used.

dialogUnitX = (pixelX * 4) / baseUnitX 
dialogUnitY = (pixelY * 8) / baseUnitY