Form.SetDesktopBounds(Int32, Int32, Int32, Int32) Methode

Definition

Legt die Grenzen des Formulars in Desktopkoordinaten fest.

public:
 void SetDesktopBounds(int x, int y, int width, int height);
public void SetDesktopBounds(int x, int y, int width, int height);
member this.SetDesktopBounds : int * int * int * int -> unit
Public Sub SetDesktopBounds (x As Integer, y As Integer, width As Integer, height As Integer)

Parameter

x
Int32

Die x-Koordinate der Position des Formulars.

y
Int32

Die y-Koordinate der Position des Formulars.

width
Int32

Die Breite des Formulars.

height
Int32

Die Höhe des Formulars.

Beispiele

Das folgende Beispiel veranschaulicht die Verwendung der SetDesktopBounds Methode. Zum Ausführen dieses Beispiels fügen Sie den folgenden Code in ein Formular ein, das eine Schaltfläche mit dem Namen Button2enthält. Stellen Sie sicher, dass alle Ereignisse ihren Ereignishandlern zugeordnet sind.

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(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 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

Hinweise

Desktopkoordinaten basieren auf dem Arbeitsbereich des Bildschirms, der die Taskleiste ausschließt. Mit dieser Methode können Sie die Position und Größe Ihres Formulars auf dem Desktop festlegen. Da Desktopkoordinaten auf dem Arbeitsbereich des Formulars basieren, können Sie diese Methode verwenden, um sicherzustellen, dass Das Formular vollständig auf dem Desktop sichtbar ist.

Gilt für:

Weitere Informationen