none
Is there a way to retrieve the physical size of the screen?

    Question

  • We will be using this information to compute for the pixel density of the screen. We need this in order to draw an object with an exact 
    size, say 1 inch, on any screen.

    Basically, what we'll be doing is have our application adjust the size of our object depending on the curent pixel density of the monitor so that 1-inch will measure exactly 1-inch when displayed on the screen.

    If you have other suggestions on how to do this, please let me know.

    Thank you.

    Wednesday, December 08, 2010 6:59 AM

Answers

  • As far as I know, there is no way to retrive the actual physical size of the screen either using .NET or Win32, and what I mean by physical size is basically how many inches your screen is. If you have a standard monitor, Windows assumes that the screen DPI is 96 dots per inch. This might not be true given the following formula:

    Screen DPI = Sqrt(Screen Resolution Width * Screen Resolution Width + Screen Resolution Height * Screen Resolution Height) / The physical size of the monitor in inches

    The actual screen DPI might be different than 96. If the screen DPI is greater than 96 but Windows assumes it is 96, then 96 pixels will be 1 inch according to Windows whereas the truth is 96 pixels will be smaller than 1 inch. 

    If you ignore the problem presented above

    On the other hand, WPF has resolution independence. If you have a high resolution monitor (meaning Windows DPI setting is greater than 96), 1 Windows-inch on a lower resolution monitor will be exactly 1 Windows-inch on the high resolution monitor. More pixels will be needed to constitute 1 inch, but you always get the same size. 
    Wednesday, December 08, 2010 7:35 AM

All replies

  • As far as I know, there is no way to retrive the actual physical size of the screen either using .NET or Win32, and what I mean by physical size is basically how many inches your screen is. If you have a standard monitor, Windows assumes that the screen DPI is 96 dots per inch. This might not be true given the following formula:

    Screen DPI = Sqrt(Screen Resolution Width * Screen Resolution Width + Screen Resolution Height * Screen Resolution Height) / The physical size of the monitor in inches

    The actual screen DPI might be different than 96. If the screen DPI is greater than 96 but Windows assumes it is 96, then 96 pixels will be 1 inch according to Windows whereas the truth is 96 pixels will be smaller than 1 inch. 

    If you ignore the problem presented above

    On the other hand, WPF has resolution independence. If you have a high resolution monitor (meaning Windows DPI setting is greater than 96), 1 Windows-inch on a lower resolution monitor will be exactly 1 Windows-inch on the high resolution monitor. More pixels will be needed to constitute 1 inch, but you always get the same size. 
    Wednesday, December 08, 2010 7:35 AM
  • Thursday, December 09, 2010 1:59 AM
  • Hello responderns5!

    Thanks for the reply!

    I think the "WPF resolution independence" thing works to a certain extent but is not exactly what would make a 1 inch button VISUALLY appear as 1 inch also on another monitor. This has been demoed in the following link:

    http://www.wpflearningexperience.com/?p=41

    This is also what happens in our applications. We were only able to display the expected dimensions if we knew all the information that we needed (screen resolution, system dpi, physical screen size). However, the only thing that we don't know how to obtain by code is the physical screen size.

    So, is there anyone from microsoft who can verify if there is a way to obtain the physical screen size?

    Thanks!

    Thursday, December 09, 2010 10:20 AM
  • Hi Bjutus,

    Thanks for your post!

    As far as I know, we cannot obtain the physical screen size. If this is critical to your business, you can send a feature request at http://connect.microsoft.com to elaborate how this will impact your business. It will be reviewed by Microsoft engineers and it might be considered in the future release of Windows.

    @repondern5: thank you for the excellent reply.

    Best regards,


    Best regards,
    Min Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, December 13, 2010 3:34 AM
    Moderator