해상도의 중심을 찾는 방법은 무엇입니까?어떤 해상도에서 화면의 중심을 찾는 방법
내 프로그램이 화면 중간에 나타나게하고 싶습니다. -10 (y 축).
는 (내 프로그램은 최대 크기가 아닌)
나는의 WinForm에서 C 번호와 함께 작동합니다.
해상도의 중심을 찾는 방법은 무엇입니까?어떤 해상도에서 화면의 중심을 찾는 방법
내 프로그램이 화면 중간에 나타나게하고 싶습니다. -10 (y 축).
는 (내 프로그램은 최대 크기가 아닌)
나는의 WinForm에서 C 번호와 함께 작동합니다.
기본 WinForm의 StartPosition
속성을 CenterScreen
으로 설정할 수 있습니다. 그런 다음이 화면 센터와 관련하여 다른 위치에 어떻게 든 나타나게하려면 Top
및 Left
속성을 사용하여 필요한 픽셀 수를 더하거나 뺍니다.
이 당신이처럼 할 수 있어야 당신에게
private void center_Load(object sender, System.EventArgs e)
{
// Position the Form on The screen taking in account
the resolution
//
Rectangle screenRect = Screen.GetBounds(Bounds);
// get the Screen Boundy
ClientSize = new Size((int)(screenRect.Width/2),
(int)(screenRect.Height/2)); // set the size of the form
Location = new
Point(screenRect.Width/2-ClientSize.Width/2,
screenRect.Height/2-ClientSize.Height/2); // Center the Location of
the form.
}
도움이 될 :
var screensize = Screen.PrimaryScreen.Bounds;
var programsize = Bounds;
Location = new Point((screensize.X-programsize.X)/2,
(screensize.Y-programsize.Y)/2 - 10);
해상도가 다른 두 개 이상의 화면이있는 경우 문제가 될 수 있습니다 ... – webber2k6
당신이 알 필요가 있다면 나는 ... 그러나, @ DarinDimitrov의 제안에 가고 싶어 계정으로 작업 표시 줄을 복용
System.Windows.Forms.Screen.PrimaryScreen.Bounds
또는 : 화면의 경계
System.Windows.Forms.Screen.PrimaryScreen.WorkingArea
... 또는 일부 변형
두 개 또는 세 개의 숫자가있는 경우 문제가 될 수 있습니다. 해상도가 다른 더 많은 스크린 ... – webber2k6
이 시도 : // MSDN :
new Point((this.Width + this.Location.X)/2 - popupControlContainer1.Width/2,
(this.Height + this.Location.Y)/2 - popupControlContainer1.Height/2)
은 당신이 [`Screen.WorkingArea`] (HTTP입니다 무엇이 필요
을 도움이되기를 바랍니다. microsoft.com/en-us/library/system.windows.forms.screen.workingarea.aspx) – V4Vendetta