Form.SetDesktopBounds(Int32, Int32, Int32, Int32) 方法   
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
以桌面坐标设置窗体的边界。
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)
	参数
- x
 - Int32
 
窗体位置的 x 坐标。
- y
 - Int32
 
窗体位置的 y 坐标。
- width
 - Int32
 
窗体的宽度。
- height
 - Int32
 
窗体的高度。
示例
以下示例演示如何使用 SetDesktopBounds 方法。 若要运行此示例,请将以下代码粘贴到包含名为 的 Button2按钮的窗体中。 确保所有事件都与其事件处理程序相关联。
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
	注解
桌面坐标基于屏幕的工作区域(不包括任务栏)。 可以使用此方法在桌面上设置窗体的位置和大小。 由于桌面坐标基于窗体的工作区域,因此可以使用此方法来确保窗体在桌面上完全可见。