[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Get device screen dimensions

Posted on 2007-11-30
3
Medium Priority
?
816 Views
Last Modified: 2013-12-21
Anyone know how to get a device's screen dimensions programmatically?
0
Comment
Question by:DotNetThinker
3 Comments
 
LVL 24

Accepted Solution

by:
alexey_gusev earned 1200 total points
ID: 20385602
for simple queries you can use System.Windows.Forms.Screen class

if you need something towards screen resolution, you can use Win32 API ChangeDisplaySettingsEx(). There are few useful wrappers for C# which you can google easily
0
 
LVL 64

Assisted Solution

by:Fernando Soto
Fernando Soto earned 800 total points
ID: 20385608
Hi DotNetThinker;

Here is how you can get the screen dimensions.

            Screen pScreen = Screen.PrimaryScreen;
            Rectangle bounds = pScreen.Bounds;
            MessageBox.Show("Width = " + bounds.Width + "\n" +
                "Height = " + bounds.Height);

If you have multiple screens then you can get an array of Screens by using AllScreens and loop through each one.

The documentation for Screens can be found at:

http://msdn2.microsoft.com/en-us/library/system.windows.forms.screen_members.aspx

Fernando
0
 
LVL 11

Author Closing Comment

by:DotNetThinker
ID: 31412038
Thanks guys
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is a real story and is one of my scariest tech experiences. Most users think that IT experts like us know how to fix all computer problems. However, if there is a time constraint and you MUST not fail the task or you will lose your job, a simple …
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month17 days, 18 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question