Export (0) Print
Expand All

ITransformProvider.Resize Method

Resizes the control.

Namespace:  System.Windows.Automation.Provider
Assembly:  UIAutomationProvider (in UIAutomationProvider.dll)

Sub Resize ( _
	width As Double, _
	height As Double _


Type: System.Double

The new width of the window, in pixels.

Type: System.Double

The new height of the window, in pixels.


If the CanResize property is false.

When called on a control that supports split panes, this method can have the side effect of resizing other contiguous panes.

An object cannot be moved, resized, or rotated such that its resulting screen location would be completely outside the coordinates of its container and inaccessible to keyboard or mouse. For example, when a top-level window is moved completely off-screen or a child object is moved outside the boundaries of the container's viewport. In these cases the object is placed as close to the requested screen coordinates as possible with the top or left coordinates overridden to be within the container boundaries.

The following example shows one possible implementation of this method for a custom control that can be resized.

		''' <summary>
		''' Resizes the provider to the specified height and width.
		''' </summary>
		''' <param name="height">The specified height.</param>
		''' <param name="width">The specified width.</param>
		Private Sub Resize(ByVal width As Double, ByVal height As Double) Implements ITransformProvider.Resize
			If Not(CType(Me, ITransformProvider)).CanResize Then
				Throw New InvalidOperationException("Operation cannot be performed.")
			End If

			If width <= 0 Or height <= 0 Then
				Throw New InvalidOperationException("Operation cannot be performed.")
			End If

            Dim widthInt As Integer = CInt(width)
            Dim heightInt As Integer = CInt(height)

			' Resize should never be allowed to place a control outside the 
			' bounds of its container; the control should always be accessible 
			' using the keyboard or mouse.
			' Use the bounds of the parent window to limit the placement 
			' of the custom control.
			Dim MaxSize As New Size(Me.customControl.formWidth - 20, Me.customControl.formHeight - 20)
			Dim MinSize As New Size(10, 10)

			If widthInt > MaxSize.Width Then
				widthInt = MaxSize.Width
			End If
			If heightInt > MaxSize.Height Then
				heightInt = MaxSize.Height
			End If
			If widthInt < MinSize.Width Then
				widthInt = MinSize.Width
			End If
			If heightInt < MinSize.Height Then
				heightInt = MinSize.Height
			End If

			' Invoke control method on separate thread to avoid clashing with UI.
            ' Use anonymous method for simplicity.
			Me.customControl.Invoke(New MethodInvoker(Sub() Me.customControl.Size = New Size(widthInt, heightInt)))
		End Sub

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
© 2015 Microsoft