C# – 해상도 구하기

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

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

 

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

this.Location = new Point(
Screen.PrimaryScreen.Bounds.Width/2 - this.Size.Width/2,
Screen.PrimaryScreen.Bounds.Height/2 - this.Size.Height/2);

 

현재 윈도우 해상도 얻기

Size Bounds = Screen.PrimaryScreen.Bounds.Size;
MessageBox.Show(Bounds.ToString());
(결과) Width=2560, Height=1600

 

작업 표시줄 제외한 윈도우 영역 크기

Size WorkingArea = Screen.PrimaryScreen.WorkingArea.Size;
MessageBox.Show(WorkingArea.ToString());
(결과) Width=2560, Height=1570 (2560*1600 해상도에서 테스트 한 결과임)

댓글 남기기