C# 获取屏幕的大小

时间:2023-03-09 08:59:26
C# 获取屏幕的大小

原文地址:http://www.cnblogs.com/zp89850/archive/2011/08/23/2151052.html

C# 获取屏幕的大小

WinForm:

int iActulaWidth = Screen.PrimaryScreen.Bounds.Width;

int iActulaHeight = Screen.PrimaryScreen.Bounds.Height ;

WPF下的:

double dWidth = System.Windows.SystemParameters.PrimaryScreenWidth;

double dHeight = System.Windows.SystemParameters.PrimaryScreenHeight;

double dWidth2 = ActualWidth; //获取此元素的呈现宽度。若此元素时全屏的,则可以获得屏幕大小(-_-!!!)

double dHeight2 = ActualHeight; //获取此元素的呈现高度。