C # Gets the size of the screen SystemInformation class

Source: Internet
Author: User

C # Get the size of the screen

WinForm:

int iactulawidth = Screen.PrimaryScreen.Bounds.Width;

int iactulaheight = Screen.PrimaryScreen.Bounds.Height;

Under WPF:

Double dwidth = System.Windows.SystemParameters.PrimaryScreenWidth;

Double dheight = System.Windows.SystemParameters.PrimaryScreenHeight;

Double dWidth2 = actualwidth; Gets the rendering width of this element. If this element is full-screen, you can get the screen size (-_-!!! )

Double dHeight2 = ActualHeight; Gets the rendering height of this element.

Using the SystemInformation class

[CSharp]

The size of the current screen in addition to the Work field outside the taskbar

String currentscreensize_outtaskbar=systeminformation.workingarea.width.tostring () + "," + SystemInformation.WorkingArea.Height.ToString ();

MessageBox.Show ("The current screen has a working field size other than the taskbar:" +currentscreensize_outtaskbar);

The current screen includes the task bar's working field size

String currentscreensize=system.windows.forms.screen.primaryscreen.bounds.width.tostring () + "," + System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height.ToString ();

MessageBox.Show ("The current screen includes the task bar's working field Size:" +currentscreensize);

Task bar Size

Size uttaskbarsize = new Size (SystemInformation.WorkingArea.Width, SystemInformation.WorkingArea.Height);

Size screensize = new Size (System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height);

Size taskbarsize;

Taskbarsize = new Size (

(Screensize.width-(screensize.width-outtaskbarsize.width)),

(Screensize.height-outtaskbarsize.height)

);

MessageBox.Show ("Taskbar size:" + taskbarsize.width + "," + taskbarsize.height);

C # Gets the size of the screen SystemInformation class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.