Form.SetDesktopBounds-Methode

Legt die Begrenzungen des Formulars in Desktopkoordinaten fest.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
Public Sub SetDesktopBounds ( _
    x As Integer, _
    y As Integer, _
    width As Integer, _
    height As Integer _
)
'Usage
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
)

Parameter

  • x
    Die x-Koordinate der Formularposition.
  • y
    Die y-Koordinate der Formularposition.
  • width
    Die Breite des Formulars.
  • height
    Die Höhe des Formulars.

Hinweise

Desktopkoordinaten beruhen auf dem Arbeitsbereich des Bildschirms, wobei die Taskleiste nicht mitgerechnet wird. Mithilfe dieser Methode können Sie die Position und Größe des Formulars auf dem Desktop festlegen. Da sich Desktopkoordinaten auf den Arbeitsbereich des Formulars beziehen, können Sie mit dieser Methode sicherstellen, dass das Formular vollständig auf dem Desktop angezeigt wird.

Beispiel

Im folgenden Codebeispiel wird die Verwendung der SetDesktopBounds-Methode veranschaulicht. Fügen Sie zum Ausführen dieses Beispiels den folgenden Code in ein Formular ein, das eine Schaltfläche mit dem Namen Button2 enthält. Stellen Sie sicher, dass allen Ereignissen der entsprechende Ereignishandler zugeordnet ist.

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

Plattformen

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

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

Form-Klasse
Form-Member
System.Windows.Forms-Namespace
SetDesktopLocation