소리소문 없이... 사랑도 명예도 이름도 남김 없이...
DexCore.net

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
반응형

'C#' 카테고리의 다른 글

신뢰사이트 등록하기  (0) 2012.02.27
System Information  (0) 2012.02.15
URL spy  (0) 2012.01.27
IE 실행 시키기  (0) 2012.01.27
원격장비 PORT 열려있는지 확인  (0) 2012.01.04