How to Make an Application Display Real Units of Measurement

Last reviewed: September 29, 1995
Article ID: Q127152
The information in this article applies to:
  • Microsoft Windows Software Development Kit (SDK) for Windows version 3.1
  • Microsoft Win32 Application Programming Interface (API) included with:

        - Microsoft Windows NT versions 3.5 and 3.51
        - Microsoft Windows 95 version 4.0
    

SUMMARY

Sometimes you need an application to display things in terms of a real unit of measurement such as an inch or millimeter. When dealing with a printer, resolution is usually given in dots per inch (DPI), which makes it easy to convert pixels to real inches. However, on a video display, resolution is given only in pixels. A given video mode will be some X pixels wide with no information as to the real dimensions of the display area.

Because there is no way to programmatically determine the real dimensions of the viewable area on a video display, it is impossible for a program to determine real output dimensions. Two manual methods for determining real output dimensions are given in this article.

MORE INFORMATION

When output is destined for a printer, the application can call GetDeviceCaps() using LOGPIXELSX and LOGPIXELSY to determine dots per real inch. However, for a video display, LOGPIXELSX and LOGPIXELSY are defined by the video driver and may vary wildly. These numbers define a logical inch, which is almost never equal to a real inch.

Applications that need to output real sizes to the video display can use one of the following two methods for determining output size:

  1. The application can ask the user what size monitor is attached. Using this value, an application can approximate the actual viewable area, and given the resolution of the output (GetDeviceCaps, HORZRES, VERTRES), the application can approximate real inches. This solution gives only an approximation of a real inch. Several factors can introduce errors into this approximation including the size adjustments on digital monitors.

  2. The application can ask the user to hold a measuring device to the screen and measure a given line. This is the only way to guarantee that output on a video display is exactly the expected size, and recalibration would be necessary after any adjustment to the monitor.


Additional reference words: 3.10 3.50 4.00 95
KBCategory: kbgraphic
KBSubcategory: GdiDisplay


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 29, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.