How to get monitor size?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Polaris

    How to get monitor size?

    Hi Experts:

    Using C#, is there a way to get the display monitor's size in inches (for
    example, I'd like to know if the monitor size is 15", 17" or whatever)?

    Thanks in Advance
    Polaris

  • Paul E Collins

    #2
    Re: How to get monitor size?

    "Polaris" <etpolaris@hotm ail.comwrote:
    Using C#, is there a way to get the display monitor's size in inches
    (for example, I'd like to know if the monitor size is 15", 17" or
    whatever)?
    SystemInformati on.PrimaryMonit orSize will give you the size in pixels
    (screen dots).

    If you really need it in inches, you can't do it in .NET, but I think
    you could use a Win32 API call to GetDeviceCaps.

    Eq.


    Comment

    • Cowboy \(Gregory A. Beamer\)

      #3
      Re: How to get monitor size?

      No guaranteed way to get inches, even what Paul has suggested, as it is not
      a required component of the interface between the monitor and Windows. You
      can, as Paul has stated, get resolution.

      --
      Gregory A. Beamer
      MVP, MCP: +I, SE, SD, DBA

      Subscribe to my blog


      or just read it:


      *************** *************** *************** ****
      | Think outside the box!
      |
      *************** *************** *************** ****
      "Polaris" <etpolaris@hotm ail.comwrote in message
      news:%23i2vZPsk IHA.6092@TK2MSF TNGP06.phx.gbl. ..
      Hi Experts:
      >
      Using C#, is there a way to get the display monitor's size in inches (for
      example, I'd like to know if the monitor size is 15", 17" or whatever)?
      >
      Thanks in Advance
      Polaris

      Comment

      • Fred Mellender

        #4
        Re: How to get monitor size?

        Once you have the monitor size in pixels
        (SystemInformat ion.PrimaryMoni torSize),
        you can get the dpi by creating a Graphics (g) and getting the Horizontal
        and Vertical pitch via g.DpiX, g.DpiY. Then you should be able to get the
        monitor size in inches via division of the PMS by the pitch.

        I haven't tried this, but it seems reasonable to me.


        "Polaris" <etpolaris@hotm ail.comwrote in message
        news:%23i2vZPsk IHA.6092@TK2MSF TNGP06.phx.gbl. ..
        Hi Experts:
        >
        Using C#, is there a way to get the display monitor's size in inches (for
        example, I'd like to know if the monitor size is 15", 17" or whatever)?
        >
        Thanks in Advance
        Polaris

        Comment

        • Polaris

          #5
          Re: How to get monitor size?

          Thanks. I tried that also, but the DpiX/DpiY didi not change when I change
          the monitor resolution. Looks like they represent native resolutions only.

          "Fred Mellender" <nospamPlease_f redm73@gmail.co mwrote in message
          news:Cg7Ij.901$ NU2.230@news01. roc.ny...
          Once you have the monitor size in pixels
          (SystemInformat ion.PrimaryMoni torSize),
          you can get the dpi by creating a Graphics (g) and getting the Horizontal
          and Vertical pitch via g.DpiX, g.DpiY. Then you should be able to get the
          monitor size in inches via division of the PMS by the pitch.
          >
          I haven't tried this, but it seems reasonable to me.
          >
          >
          "Polaris" <etpolaris@hotm ail.comwrote in message
          news:%23i2vZPsk IHA.6092@TK2MSF TNGP06.phx.gbl. ..
          >Hi Experts:
          >>
          >Using C#, is there a way to get the display monitor's size in inches (for
          >example, I'd like to know if the monitor size is 15", 17" or whatever)?
          >>
          >Thanks in Advance
          >Polaris
          >
          >

          Comment

          • Phil

            #6
            DPI vs PPI

            DPI (dots per inch) isn't the same thing as PPI (pixels per inch). The only way to get the true PPI of the current display is to divide the current resolution (width/height) by the monitors width and height in inches. Outside GetDeviceCaps, I don't believe there is a straightforward way to get the phisycal dimensions of the display.

            DPI refers to ink droplet density in a priner matrix.

            Comment

            Working...