BBC BASIC for Windows
Programming >> User Interface >> Screen size
http://bb4w.conforums.com/index.cgi?board=ui&action=display&num=1378399178

Screen size
Post by Matt on Sep 5th, 2013, 4:39pm

Hi,

I've been playing around with various windows functions and the SYS "GetDeviceCaps", @memhdc%, HORZSIZE seems to give the wrong size. (I'm assuming that @memhdc% is the right DC to give reference to the screen.) Although HORZRES, VERTRES, LOGPIXELSX, LOGPIXELSY gives the correct values, HORZSIZE and VERTSIZE give incorrect almost twice what it should be. Is this me missing something, or is it the system reporting incorrectly?

Matt


Re: Screen size
Post by admin on Sep 5th, 2013, 5:23pm

on Sep 5th, 2013, 4:39pm, Matt wrote:
Is this me missing something, or is it the system reporting incorrectly?

It's extremely unlikely that there is a fault in the API that Microsoft are unaware of, and if by any chance that is the case you should be reporting it to them, not here! wink

By my reckoning the relationship between HORZRES (which returns pixels) and HORZSIZE (which returns 'millimetres') is as follows:

millimetres = pixels / DPI * 25.4

In other words divide the number of pixels by the dots-per-inch value to give inches, and then multiply by the number of millimetres in an inch.

If you appear to be getting the wrong value back the first thing I would check is that the DPI setting on your PC really does correspond, at least approximately, to the pixels-per-inch value for your display. It is not uncommon for the DPI to be set to 96 (the 'standard' value) even when the display is nowhere near that.

There is a table of DPI values for various display sizes here:

http://bb4w.wikispaces.com/Supporting+different+DPI+values

Richard.
Re: Screen size
Post by Matt on Sep 5th, 2013, 8:24pm

on Sep 5th, 2013, 5:23pm, Richard Russell wrote:
If you appear to be getting the wrong value back the first thing I would check is that the DPI setting on your PC really does correspond, at least approximately, to the pixels-per-inch value for your display. It is not uncommon for the DPI to be set to 96 (the 'standard' value) even when the display is nowhere near that.

Yes, thanks. By my calculation the dpi value should be 122 rather than the 96 standard it's set at. Putting it to 122 sets the standard fonts too small to read comfortably, which is probably why it's set so. But the system's calculations seem to be OK.

Thanks

Matt
Re: Screen size
Post by admin on Sep 5th, 2013, 10:36pm

on Sep 5th, 2013, 8:24pm, Matt wrote:
Putting it to 122 sets the standard fonts too small to read comfortably, which is probably why it's set so.

Ahem - changing the DPI value from 96 to 120 increases the font size by 25%! So a typical font size of, say, 12 point will be about 16 pixels high at 96 DPI but about 20 pixels high at 120 DPI.

Richard.
Re: Screen size
Post by Matt on Sep 6th, 2013, 04:38am

on Sep 5th, 2013, 10:36pm, Richard Russell wrote:
Ahem - changing the DPI value from 96 to 120 increases the font size by 25%! So a typical font size of, say, 12 point will be about 16 pixels high at 96 DPI but about 20 pixels high at 120 DPI.

You're absolutely right. I'd fiddled around with the setting so much and my mind was on something else as well, that I was obviously not thinking. Now that I'm more than half awake this morning - The font size of 122 increases the size unusableably on my small screen. (Although, if I was doing something that was absolutely necessary to require an acurate size match I might be tempted.) I also tried 1/2 size to see what that was like and that was too small to be useful.

Thanks Richard.