By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,122 Members | 1,508 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,122 IT Pros & Developers. It's quick & easy.

How to get monitor size?

P: n/a
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

Mar 31 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"Polaris" <et*******@hotmail.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)?
SystemInformation.PrimaryMonitorSize 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.
Mar 31 '08 #2

P: n/a
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
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

*************************************************
| Think outside the box!
|
*************************************************
"Polaris" <et*******@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP06.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

Mar 31 '08 #3

P: n/a
Once you have the monitor size in pixels
(SystemInformation.PrimaryMonitorSize),
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" <et*******@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP06.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

Mar 31 '08 #4

P: n/a
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" <no******************@gmail.comwrote in message
news:Cg***************@news01.roc.ny...
Once you have the monitor size in pixels
(SystemInformation.PrimaryMonitorSize),
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" <et*******@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP06.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

Mar 31 '08 #5

P: n/a
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.
Jun 27 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.