Member No.: 1
Joined: 12-May 04
Thanks hare for the good words and the VERY good question (this is why I moved this topic to the FAQ forum).
Please bare in mind that this is how the Windows OS is designed and WinAsm Studio simply obeys the rules:
Each dialog box template contains measurements that specify the position, width, and height of the dialog box and the controls it contains. These measurements are device independent, so an application can use a single template to create the same dialog box for all types of display devices. This ensures that a dialog box will have the same proportions and appearance on all screens despite differing resolutions and aspect ratios between screens. Practically, this how one should make the tranformation from pixels to dialog units and vice versa:
This is from the Win32 Programmer's Reference:
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.
This function has no parameters.
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.
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 * / baseunitY
The multiplication is performed before the division to avoid rounding problems if base units are not divisible by 4 or 8.
Do not use GetDialogBaseUnits to calculate baseunitX and baseunitY If the Dialog does not use the system font. Use GetTextExtentPoint32 instead.
I hope it helps. If you still have questions, please let me know