Compartir a través de


PenInputPanel.Width Property

PenInputPanel.Width Property

Gets the width of the pen input panel in client coordinates.

Definition

Visual Basic .NET Public ReadOnly Property Width As Integer
C# public int Width { get; }
Managed C++ public: __property int* get_Width();

Property Value

System.Int32. The width of the pen input panel in client coordinates.

This property is read-only. This property has no default value.

Exceptions

ObjectDisposedException Leave Site:

Remarks

The width of the PenInputPanel object is dependent on the screen resolution for the particular Tablet PC. The default value at 96 dots per inch (dpi) is 570 pixels. The default value at 120 dpi is 712 pixels. The default value at 133 dpi is 790 pixels.

Starting with Microsoft® Windows® XP Tablet PC Edition with Windows XP Service Pack 2 (SP2), the Tablet PC Input Panel allows the user to continue entering handwriting by automatically increasing the size of the Input Panel to accomodate new handwriting. The Height and Width properties do not update to reflect the new size as the Input Panel grows. These properties return the original size of the Input Panel. They also do not report the dimensions of the Input Panel hover target.

Examples

[C#]

This C# example creates a PenInputPanel object, thePenInputPanel, and attaches it to an InkEdit control, inkEdit1. It then attaches a VisibleChanged event handler, VisibleChanged_Event. In the event handler, it adds a sentence to the content of the edit control to which the PenInputPanel is attached. The sentence states the width of the pen input panel in pixels by retrieving the Width property and converting it to a string with the ToString Leave Site 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(inkEdit1);

    // Add a VisibleChanged 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;

        // When the panel has become visible...
        if (e.NewVisibility)
        {
            // Display the width of the panel in the attached edit control
            theSenderPanel.AttachedEditControl.Text +=
                    "The width of the panel is ";
            theSenderPanel.AttachedEditControl.Text +=
                     theSenderPanel.Width.ToString();
            theSenderPanel.AttachedEditControl.Text += " pixels.\n";
        }
    }
}

[Visual Basic .NET]

This Microsoft Visual Basic® .NET example creates a PenInputPanel object, thePenInputPanel, and attaches it to an InkEdit control, InkEdit1. It then attaches a VisibleChanged event handler, VisibleChanged_Event. In the event handler, it adds a sentence to the content of the edit control to which the PenInputPanel is attached. The sentence states the width of the pen input panel in pixels by retrieving the Width property and converting it to a string with the ToString Leave Site method.

'...

' Declare the PenInputPanel object
Dim thePenInputPanel As PenInputPanel

Public Sub New()
    MyBase.New()

    ' Required for Windows Form Designer support
    InitializeComponent()

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

    ' Add a VisibleChanged 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)

       ' When the panel has become visible...
       If e.NewVisibility Then
          ' Display the width of the panel in the attached edit control
          theSenderPanel.AttachedEditControl.Text += _
                   "The width of the panel is "

          theSenderPanel.AttachedEditControl.Text += _
                   theSenderPanel.Width.ToString()

         theSenderPanel.AttachedEditControl.Text += _
                  " pixels." + ControlChars.Lf
       End If
    End If
End Sub 'VisibleChanged_Event

See Also