듀얼 모니터를 쓸 일이 있다 공연이라던지, 아님 전시회에서라던지...

이러한 경우 가끔씩 듀얼모니터와 관련된 프로그래밍을 할 경우가 아주 가끔씩 있는데 이럴때 AllScreens 라는 것을 이용하면 간단하게 해결된다.

필수 네이스페이스는

using System.Windows.Forms;

가 되겠다.

기본적인 다이얼로그(폼) 베이스에서 시작을 하면 위의 네임스페이스는 기본 포함 된다.

사용법은 간단하다. 듀얼 모니터 사용할 경우 폼이 2개라 가정하고. 코드를 작성하면

private void theOtherMonitorGetSize()
{
Screen[] sc;
sc = Screen.AllScreens;
player.Left = sc[1].Bounds.Width;
player.Top = sc[1].Bounds.Height;

player.PlayerSize(player.Left, player.Top);

player.StartPosition = FormStartPosition.Manual;
player.Location = sc[1].Bounds.Location;
Point p = new Point(sc[1].Bounds.Location.X, sc[1].Bounds.Location.Y);
player.Location = p;
player.WindowState = FormWindowState.Maximized;
}

AllScreens의 경우 현재 모니터의 수를 배열로 저장을 하는데 0번은 메인 모니터 1번이상은 다른 모니터들이다.

참고로 저 소스는 다른 모니터에 맞게 폼을 최대화 시키는 것이다. player같은 경우는 다른폼을 나타내는 인스턴스이다.

FullScreen모드로 속이기 위하여 ㅡㅡ;;;

Posted by 요지
,