Solved

Get device screen dimensions

Posted on 2007-11-30
3
811 Views
Last Modified: 2013-12-21
Anyone know how to get a device's screen dimensions programmatically?
0
Comment
Question by:DotNetThinker
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 24

Accepted Solution

by:
alexey_gusev earned 300 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 63

Assisted Solution

by:Fernando Soto
Fernando Soto earned 200 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

This article summaries thoughts and ideas from two years of sustained use. It provides good reasoning to make the jump to Windows 10.
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
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…

690 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