C#
C# 모니터 해상도 구하기
휘프노스
2016. 2. 16. 16:54
C#에서 윈도우즈의 해상도를 가져오는 방법은 다음과 같다.
1.
Screen.PrimaryScreen.Bounds.Width
Screen.PrimaryScreen.Bounds.Height
Screen.PrimaryScreen.Bounds.Height
2.
System.Windows.Forms.SystemInformation.VirtualScreen.Width;
System.Windows.Forms.SystemInformation.VirtualScreen.Height;
윈도우 폼에서 위치를 지정해서 나타나게 할 때는
int x = Screen.PrimaryScreen.Bounds.Width / 2;
int y = Screen.PrimaryScreen.Bounds.Height / 2;
this.Location = new Point(x, y);
위와 같이 Location 값을 재 설정해서 스크린 중앙에 나타나게 설정하거나 원하는 위치를 시작지점으로 설정할 수 있다.
이 때 StartPosition 속성은 영향을 미치지 않는다.
1, 2 의 차이점은 듀얼모니터를 쓸경우 1은 모니터 1대의 해상도를 가져오고 2는 2대를 합한 전체 해상도를 가져온다.
참조링크