Solved

Get device screen dimensions

Posted on 2007-11-30
3
805 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 300 total points
Comment Utility
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 62

Assisted Solution

by:Fernando Soto
Fernando Soto earned 200 total points
Comment Utility
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
Comment Utility
Thanks guys
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

A short article about problems I had with the new location API and permissions in Marshmallow
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup". After a while, you have entered a loop for Auto repair which does not fix anything and you will be in a  panic as all your work w…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

744 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now