Return to Index
created by gbSnippets
The size of the dialog font proportionately affects the conversion
of dialog units values into pixels, so an increase in default font
size will automatically create a larger dialog, even through the
dialog dimensions have remained constant.
Dialog box and control dimensions and coordinates are device-independent.
Because a dialog box may be displayed on system displays that have widely
varying pixel resolutions, dialog box dimensions are specified in
system-character widths and heights instead of pixels.
This helps to ensure the best possible appearance of characters in the
dialog, and enables dialog boxes to appear with similar proportions and
appearance on the screen, even when the resolution and aspect ratio can
The dialog box base units are computed from the height and width of the
system font. As the display resolution is changed, Windows changes the
system font size accordingly, thereby adjusting the dialog unit size
proportionally to the resolution.
By default, the actual font used in 's Dynamic Dialog Tools (DDT)
dialogs is 8 point "MS Sans Serif". When designing your dialogs, it is a
good idea to make controls slightly wider and taller than the text label
size. This additional tolerance helps to ensure that the text is not clipped
if the default dialog font is slightly larger in some resolutions. You can
also use the DIALOG FONT statement to specify a custom default DDT font.
You can convert between Dialog Units and Pixels with the built in DIALOG PIXELS
and DIALOG UNITS statements.
This is one way of adding some accessibility to an application with very little effort.
By Chris Boss
Dialog Units do have a down side, so it is best to work with pixels and then calculate any conversion to other coordinate systems (scaling) when needed.
A little history about the dialog unit.
A Dialog Unit is dependent upon the font used for defining the dialog. Dialog Units have been around some time and in the old days, the System Font (fixed width) was the default font in windows. When converting a dialog unit to pixels, using the systom font, a dialog unit came out as 2 pixels (both horz. and vert.).
Thats not bad. Dialog units would just be large pixels (2 x 2 pixels) and it would allow some exactness.
As time when on, other fonts became more prominent in Windows and the System font is not used that much. Variable width fonts such as MS Sans Serif became the norm as a default font for 's.
Now a problem comes about, because these other fonts do not produce dialog units which divide out nicely into pixels.
Dialog Units are really a division of the average character size of a font.
One calculates the average character size for a font and the dialog unit is:
X Dialog Unit is 1/4 of character width
Y dialog unit is 1/8 of character height
The system font character size is 8 x 16 pixels, so you can see how the dialog unit comes out to be 2 x 2 pixels.
Now with DDT, the default font used comes out to 6 x 13 pixels (trust me on this one, I have done a lot of testing of 's dialog units).
This means that the dialog units for the default DDT font are:
X dialog unit is 6 / 4 which is 1.5 pixels
Y dialog unit is 13 / 8 which is 1.625 pixels
Can you see the problem here ?
This is why with DDT (default font), dialog units only work best with character units (6 x 13 pixels) and not individual units.
Now the current version of DDT allows you to define dialogs using pixels, which helps a great deal. The problem is that using pixels defeats the built in scaling of dialog units. Dialog units are scalable, pixels are not.
One could use the system font (fixed width) for dialogs and you would have a bit better correlation between dialog units and pixels.
The Windows messages (ie. WM_LBUTTONUP, WM_MOUSEMOVE) all work with pixels and not dialog units, so it makes sense to work with pixels when dealing with those messages.
created by gbSnippets