Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

How to get monitor size?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Polaris - 31 Mar 2008 01:11 GMT
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 - 31 Mar 2008 01:53 GMT
> 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.
Cowboy (Gregory A. Beamer) - 31 Mar 2008 03:06 GMT
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.

Signature

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!

*************************************************
> Hi Experts:
>
[quoted text clipped - 3 lines]
> Thanks in Advance
> Polaris
Fred Mellender - 31 Mar 2008 16:17 GMT
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.

> Hi Experts:
>
[quoted text clipped - 3 lines]
> Thanks in Advance
> Polaris
Polaris - 31 Mar 2008 22:49 GMT
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.

> Once you have the monitor size in pixels
> (SystemInformation.PrimaryMonitorSize),
[quoted text clipped - 11 lines]
>> Thanks in Advance
>> Polaris

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.