다음을 통해 공유


Form.SetDesktopBounds 메서드

폼의 경계를 데스크톱 좌표로 설정합니다.

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
Public Sub SetDesktopBounds ( _
    x As Integer, _
    y As Integer, _
    width As Integer, _
    height As Integer _
)
‘사용 방법
Dim instance As Form
Dim x As Integer
Dim y As Integer
Dim width As Integer
Dim height As Integer

instance.SetDesktopBounds(x, y, width, height)
public void SetDesktopBounds (
    int x,
    int y,
    int width,
    int height
)
public:
void SetDesktopBounds (
    int x, 
    int y, 
    int width, 
    int height
)
public void SetDesktopBounds (
    int x, 
    int y, 
    int width, 
    int height
)
public function SetDesktopBounds (
    x : int, 
    y : int, 
    width : int, 
    height : int
)

매개 변수

  • x
    폼 위치의 x 좌표입니다.
  • y
    폼 위치의 y 좌표입니다.
  • width
    폼의 너비입니다.
  • height
    폼의 높이입니다.

설명

데스크톱 좌표는 작업 표시줄을 제외한 화면의 작업 영역을 기반으로 합니다. 이 메서드를 사용하면 데스크톱에서 폼의 위치 및 크기를 설정할 수 있습니다. 데스크톱 좌표는 폼의 작업 영역을 기반으로 하므로 이 메서드를 사용하여 데스크톱에 폼이 완전히 표시되도록 할 수 있습니다.

예제

다음 코드 예제에서는 SetDesktopBounds 메서드를 사용하는 방법을 보여 줍니다. 이 예제를 실행하려면 Button2라는 단추가 들어 있는 폼에 다음 코드를 붙여넣습니다. 또한 모든 이벤트가 해당 이벤트 처리 메서드와 연결되어 있어야 합니다.

Private Sub Button2_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button2.Click
    Dim i As Integer
    For i = 0 To 20
        ' With each loop through the code, the form's desktop location is 
        ' adjusted right and down by 10 pixels and its height and width 
        ' are each decreased by 10 pixels. 
        Me.SetDesktopBounds(Me.Location.X + 10, Me.Location.Y + 10, _
            Me.Width - 10, Me.Height - 10)

        ' Call Sleep to show the form gradually shrinking.
        System.Threading.Thread.Sleep(50)
    Next
End Sub
private void Button2_Click(System.Object sender, System.EventArgs e)
{
    
    for(int i = 0; i <= 20; i++)
    {
        // With each loop through the code, the form's 
        // desktop location is adjusted right and down
        //  by 10 pixels and its height and width are each
        // decreased by 10 pixels. 
        this.SetDesktopBounds(this.Location.X+10, 
            this.Location.Y+10, this.Width-10, this.Height-10);

        // Call Sleep to show the form gradually shrinking.
        System.Threading.Thread.Sleep(50);
    }
}
void Button2_Click( System::Object^ sender, System::EventArgs^ e )
{
   for ( int i = 0; i <= 20; i++ )
   {
      
      // With each loop through the code, the form's 
      // desktop location is adjusted right and down
      //  by 10 pixels and its height and width are each
      // decreased by 10 pixels. 
      this->SetDesktopBounds( this->Location.X + 10, this->Location.Y + 10, this->Width - 10, this->Height - 10 );
      
      // Call Sleep to show the form gradually shrinking.
      System::Threading::Thread::Sleep( 50 );

   }
}
private void button2_Click(Object sender, System.EventArgs e)
{
    for (int i = 0; i <= 20; i++) {
        // With each loop through the code, the form's 
        // desktop location is adjusted right and down
        // by 10 pixels and its height and width are each
        // decreased by 10 pixels. 
        this.SetDesktopBounds(this.get_Location().get_X() + 10, 
            this.get_Location().get_Y() + 10, this.get_Width() - 10, 
            this.get_Height() - 10);
        // Call Sleep to show the form gradually shrinking.
        System.Threading.Thread.Sleep(50);
    }
} //button2_Click

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

참고 항목

참조

Form 클래스
Form 멤버
System.Windows.Forms 네임스페이스
SetDesktopLocation