Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
This 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 specified in dialog box templates, to pixels, and vice versa.
LONG GetDialogBaseUnits( void );
Return Values
A 32-bit value that contains the dialog base units indicates success. 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.
Windows CE does not support any extended error values for this function.
Remarks
The results returned by GetDialogBaseUnitsare always derived from the system font. For both fixed pitch and variable pitch fonts, the horizontal base unit returned by GetDialogBaseUnitsis equal to the average width, in pixels, of all of the uppercase and lowercase Roman characters; the vertical base unit is equal to the height, in pixels, of the font.
You can use the GetTextMetricsand GetTextExtentPoint32functions to calculate these values for a selected font. However, by using the MapDialogRectfunction, you can avoid errors that might result if your calculations differ from those performed by the system.
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, use the following formulas:
pixelX = (templateunitX * baseunitX) / 4 pixelY = (templateunitY * baseunitY) / 8
Similarly, to convert from pixels to dialog template units, use the following formulas:
templateunitX = (pixelX * 4) / baseunitX templateunitY = (pixelY * 8) / baseunitY
The multiplication is performed before the division to avoid rounding problems if base units are not divisible by 4 or 8.
Requirements
Runs on | Versions | Defined in | Include | Link to |
---|---|---|---|---|
Windows CE OS | 1.0 and later | Winuser.h | Dlgmgr.lib |
Note This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.
See Also
GetTextExtentPoint32, GetTextMetrics, MapDialogRect, HIWORD, LOWORD,