Compartilhar via


PenInputPanel.MoveTo Method

PenInputPanel.MoveTo Method

Sets the position of the PenInputPanel object to a defined screen position.

Definition

Visual Basic .NET Public Sub MoveTo( _
ByVal left As Integer, _
ByVal top As Integer _
)
C# public void MoveTo(
int left,
int top
);
Managed C++ public: void MoveTo(
int *left,
int *top
);

Parameters

left System.Int32. The new x-axis position of the left edge of the PenInputPanel object, in screen coordinates.
top System.Int32. The new y-axis position of the top edge of the PenInputPanel object, in screen coordinates.

Exceptions

COMException Leave Site:
ObjectDisposedException Leave Site:

Remarks

The MoveTo method causes an error if the control to which the PenInputPanel object is attached does not have focus. This method can be safely called if the pen input panel is not visible, as long as the attached control has focus.

If the new position causes the panel to appear outside the boundary of the screen working area, the panel is shifted toward the center of the working area so that the edges of the panel are adjacent to the nearest edges of the screen.

To explicitly override the automatic positioning behavior of the PenInputPanel object, use the Left and Top properties of the PenInputPanel object to determine its current position. If the PenInputPanel is located on a section of the screen that should be visible, use the MoveTo method to relocate the PenInputPanel.

You can also override the automatic positioning behavior of the PenInputPanel object by monitoring to the Left and Top properties of the PenInputPanelMovingEventArgs object during a PanelMoving event. If the PenInputPanel is located on a section of the screen that should be visible, use the MoveTo method to relocate the PenInputPanel.

When the MoveTo method is called, the Tablet PC Input Panel hover target is disabled.

Examples

[C#]

This C# example attaches a PenInputPanel object, thePenInputPanel, to an InkEdit control, theInkEdit. It adds a VisibleChanged event handler, VisibleChanged_Event, to the form for the PenInputPanel. In the event handler, if the PenInputPanel object is visible, its position is changed to screen coordinates (100, 100) by calling the MoveTo method.

//...

// Delcare the PenInputPanel object
PenInputPanel thePenInputPanel;

public Form1()
{
    // Required for Windows Form Designer support
    InitializeComponent();

    // Create and attach the new PenInputPanel to an InkEdit control.
    thePenInputPanel = new PenInputPanel(theInkEdit);

    // Add a PenInputPanelVisibleChanged event handler
    thePenInputPanel.VisibleChanged +=
        new PenInputPanelVisibleChangedEventHandler(VisibleChanged_Event);
}

//...

public void VisibleChanged_Event(object sender,
PenInputPanelVisibleChangedEventArgs e)
{
    // Make sure the object that generated
    // the event is a PenInputPanel object
    if (sender is PenInputPanel)
    {
        PenInputPanel theSenderPanel = (PenInputPanel)sender;

        // If the panel has become visible...
        if (e.NewVisibility)
        {
            // Move the pen input panel to
            // screen position (100, 100)
            theSenderPanel.MoveTo(100, 100);
        }
    }
}

[Visual Basic .NET]

This Microsoft® Visual Basic® .NET example attaches a PenInputPanel object, thePenInputPanel, to an InkEdit control, theInkEdit. It adds a VisibleChanged event handler, VisibleChanged_Event, to the form for the PenInputPanel. In the event handler, if the PenInputPanel object is visible, its position is changed to screen coordinates (100, 100) by calling the MoveTo method.

'...

' Declare the PenInputPanel object
Dim thePenInputPanel As PenInputPanel

Public Sub New()
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    ' Create and attach the new PenInputPanel to an InkEdit control.
    thePenInputPanel = New PenInputPanel(theInkEdit)

    ' Add a PenInputPanelVisibleChanged event handler
    AddHandler thePenInputPanel.VisibleChanged, _
               AddressOf VisibleChanged_Event
End Sub 'New

'...

Public Sub VisibleChanged_Event(sender As Object, e As _
                                PenInputPanelVisibleChangedEventArgs)
    ' Make sure the object that generated
    ' the event is a PenInputPanel object
    If TypeOf sender Is PenInputPanel Then
       Dim theSenderPanel As PenInputPanel = CType(sender, PenInputPanel)

       ' If the panel has become visible...
       If e.NewVisibility Then
          ' Move the pen input panel to
          ' screen position 100, 100
            theSenderPanel.MoveTo(100, 100)
       End If
    End If
End Sub 'VisibleChanged_Event