none
SetMapMode

    Question

  • Hello,

    I am writing an application in which it is important that, when I am drawing a 10 cm line, it really measure 10 cm.  So, I work in a Low Metric Map Mode (SetMapMode(MM_LOMETRIC)).

    Under Windows XP, this is working perfectly : the Viewport Extents corresponds to the the screen resolution (GetViewportExt returns (1024, 768) and the Window Extents corresponds to the size (in tenth of millimeters) of my screen. If I change the screen resolution, the viewport extents change accordingly and the window extents remain the same and my 10 cm line still measure 10 cm.  Perfect.

    Under Windows Vista and Windows 7, this is no more true.  When I call SetMapMode(MM_LOMETRIC), the viewport extents are still the screen resolution but the window extents are no more correct.   If I change the screen resolution, the Window Extents are also changing (while the physical dimensions of my screen of course remains the same).  If I increase the resolution, the drawing looks smaller and smaller.

    Under Windows Vista and Windows 7, it seems that the window extents are calculated from the Screen resolution assuming a 72 DPI ratio.  If I set the screen resolution to (1024, 768), GetWindowExt will return (3612, 2709).  (3612 = 1024 divided by 72 to get a width in inches and then multipled by 254 to get it in tenth of millimeters).

    Is it a Windows Vista/7 that will be fixed ?  Is there a way to detect the screen size properly so that I could call SetWindowExt with the proper parameters myself and get the result I want.

    Thanks in advance for your help.

    Monday, November 28, 2011 12:55 PM

All replies

  • Philippe Ber wrote:
    >
    >I am writing an application in which it is important that, when I am
    >drawing a 10 cm line, it really measure 10 cm.  So, I work in a Low
    >Metric Map Mode (SetMapMode(MM_LOMETRIC)).
    >...
    >Under Windows Vista and Windows 7, it seems that the window extents
    >are calculated from the Screen resolution assuming a 72 DPI ratio.
     
    This was the old small / large fonts issue.
     
    >Is it a Windows Vista/7 that will be fixed ?  Is there a way to detect
    >the screen size properly so that I could call SetWindowExt with the
    >proper parameters myself and get the result I want.
     
    If you need a true real-world measurement on the screen, the ONLY option is
    to display a ruler and have the user calibrate it with a real ruler.  The
    Windows API doesn't necessarily know the actual size of your monitor.
    Without that, of course, there is no way to compute the actual dots per
    inch.  Your graphics driver makes an assumption (usually either 72, 96, or
    120).  The fact that it worked on XP is mostly an accident, and then only
    on your one system.
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.
     

    Tim Roberts, VC++ MVP Providenza & Boekelheide, Inc.
    Tuesday, November 29, 2011 5:21 AM
  • Thank you Tim for your reply.

    I have already created a ruler that the user can calibrate but I would like to avoid that.

    I am quite sure that it was not an accident that it worked on XP.  I could test it on 2 laptops of the same model : on the first one XP was installed and on the second one Windows 7 was installed.  The behaviour was completely different (even when the DPI settings is set to 100 % on both).

    An accident would not explain why the Window Extents remain the same when I change the resolution on XP (passing from 800 x 600 to 1152 x 864 for instance) while under Windows 7, changing the resolution results in different Window Extent.

    I am wondering if XP was not using the EDID information (horizontal and vertical display size) in some way (as it should I think) and if this has not been broken with VISTA (in which a 72 DPI scaling factor seems to be always used).

    http://en.wikipedia.org/wiki/Extended_display_identification_data

    http://e-t172.net/blog/wp-content/uploads/2010/09/edid-manager.png

    Thanks again for your help.

     

    Tuesday, November 29, 2011 5:48 PM
  • Are You sure, cancellation of using EDID and real monitor's size in  Windows Vista/7 is not a bug?
    Friday, April 27, 2012 1:37 PM
  • Did You have found decision?

    Did You try SetProcessDPIAware call or similar tag in manifest?

    Friday, April 27, 2012 1:40 PM
  • I think also that it is a bug in Windows Vista/7.

    GetDeviceCaps(hDC, HORZSIZE) and GetDeviceCaps(hDC, VERTSIZE) are also returning wrong values but consistent with the WindowExt in MapMode MM_LOMETRIC.

    Using a DPIAware manifest doesn't help fixing that problem (but I use a DPIAware manifest to avoid the blurry display on HighDPI screen).

    For the moment, I have a ruler allowing the user to zoom the display to have it at the right scale... but I would like to avoid it.

    Friday, May 11, 2012 1:03 PM