Form.SetDesktopBounds(Int32, Int32, Int32, Int32) Método

Definição

Define os limites do formulário em coordenadas da área de trabalho.

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)

Parâmetros

x
Int32

A coordenada x da localização da forma.

y
Int32

A coordenada y da localização do formulário.

width
Int32

A largura da forma.

height
Int32

A altura da forma.

Exemplos

O exemplo seguinte demonstra o uso do SetDesktopBounds método. Para executar este exemplo, cole o seguinte código numa forma que contenha um botão chamado Button2. Certifique-se de que todos os eventos estão associados aos seus gestores de eventos.

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

Observações

As coordenadas do ambiente de trabalho baseiam-se na área de trabalho do ecrã, que exclui a barra de tarefas. Pode usar este método para definir a posição e o tamanho do formulário no ambiente de trabalho. Como as coordenadas do ambiente de trabalho são baseadas na área de trabalho do formulário, pode usar este método para garantir que o seu formulário é completamente visível no computador.

Aplica-se a

Ver também