LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Sat May 22, 2010 4:52 pm Post subject: Logical screen dpi |
|
|
In my experience, FTN95/Clearwin programs are relatively insensitive to the user choice of standard or large fonts, although there are occasional cases where it matters a lot.
The case which continues to give me problems is in the spacing of %tb toolbar icons if a non-standard "Logical dpi" setting is in effect. Ordinarily, the spacing of toolbar icons set with %tb or %ib is handled perfectly well by Clearwin. The case where it is not handled well is where the icons are expected to touch, thus forming a continuous bar (as, for example, one sees in the Office 2003 suite). Then, what looks like an arbitrary amount of extra spacing is added by Windows/Clearwin (I don't know which), although it is not actually arbitrary but is a matter of the "logical average character width" on the basis of which things are spaced out.
I have found 3 workarounds. In the first, there is a different set of icons for use when a non-standard fonts setting is enabled. In the second, I "slide" an appropriate bitmap under the icons so that the gaps don't show - this is possible with %bm, as the toolbar buttons always present themselves in the foreground. The third workaround is to space the buttons pixel by pixel. In all cases, it is necessary to do the adjustments while "building" the toolbar. That means knowing whether the "Large fonts" or "Custom size" setting has been enabled. I suppose there is a fourth option, and that is not to use %tb.
In all cases (except the last), it is necessary to detect whether or not the font size selected is "Standard".
Using functions documented in FTN95.chm, it is difficult to find the font size setting, as although the "Logical pixels in x" parameter can be retrieved from a current drawing surface once one has been created by means of (and using the handle iHDC to a %gr drawing surface):
Code: | CALL Get_Current_DC@ (iHDC)
ixdpi = GetDeviceCaps(iHDC, LOGPIXELSX)
iydpi = GetDeviceCaps(iHDC, LOGPIXELSY) |
this definitely doesn't work for the screen, and once a drawing surface has been created, it is too late to do toolbars. It seems that ixdpi=96 and iydpi=96 are the "standard" settings, and the "large fonts" setting is 120 for both. Presumably, "Custom" means anything else, and differences in the x and y settings mean that the pixels aren't square, which I haven't seen for a while.
Amazingly, the answer turns out to be trivial, as the device context for the monitor can be found using
after which GetDeviceCaps works.
I hope that this is of some use to somebody out there.
Eddie |
|