C#

Monitor size 구하기

탑~! 2012. 2. 3. 11:41
 int width = System.Windows.Forms.SystemInformation.PrimaryMonitorSize.Width;
 int height = System.Windows.Forms.SystemInformation.PrimaryMonitorSize.Height;

C#에서 윈도우즈의 해상도를 가져오는 방법은 다음과 같다.

1.

Screen.PrimaryScreen.Bounds.Width
Screen.PrimaryScreen.Bounds.Height

2.

System.Windows.Forms.SystemInformation.VirtualScreen.Width;

System.Windows.Forms.SystemInformation.VirtualScreen.Height;


이를 이용해 폼을 윈도우즈의 정중앙에 띄울수 도 있다.

this.Location = new Point(

Screen.PrimaryScreen.Bounds.Width/2 - this.Size.Width/2,

Screen.PrimaryScreen.Bounds.Height/2 - this.Size.Height/2

);

1, 2 의 차이점은 듀얼모니터를 쓸경우 1은 모니터 1대의 해상도를 가져오고 2는 2대를 합한 총 해상도를 가져옵니다.
728x90
반응형