Bagikan melalui


RealTimeStylus.RealTimeStylus Constructor

RealTimeStylus.RealTimeStylus Constructor

Creates a RealTimeStylus object, attaches it to the specified window, and restricts ink collection to the specified tablet.

Definition

Visual Basic .NET Public Sub RealTimeStylus( _
ByVal handle As IntPtr, _
ByVal tablet As Tablet _
)
C# public RealTimeStylus(
IntPtr handle,
Tablet tablet
);
Managed C++ public: RealTimeStylus(
IntPtr *handle,
Tablet *tablet
);

Parameters

handle System.IntPtr. The handle of the window to which to attach the RealTimeStylus object. If this parameter is set to 0, the RealTimeStylus object is not attached it to a window or control.
tablet Microsoft.Ink.Tablet. The tablet on which to collect ink, or null (Nothing in Microsoft® Visual Basic® .NET) to allow ink collection on any attached tablet.

Exceptions

ArgumentException Leave Site: One of the parameters is not valid.
InvalidOperationException Leave Site: Initialization failed.

Remarks

For new RealTimeStylus objects, ink collection is initially disabled and the input region is set to the bounds of the window to which the RealTimeStylus object is attached. For more information, see the Enabled and WindowInputRectangle properties.

When the RealTimeStylus object is created with the default constructor or with a constructor with the handle parameter set to 0 or the attachedControl parameter set to null, then the RealTimeStylus object does not collect ink from a window or control. Instead, the only way to receive ink input is by cascading this RealTimeStylus object under one that is receiving ink input from a window or control. For more information on cascading the RealTimeStylus, see The Cascaded RealTimeStylus Model.

When the handle parameter is specified and not set to 0, the RealTimeStylus object is attached to and receives ink input from the specified window.

When the tablet parameter is specified, its value determines on which tablets the RealTimeStylus object collects ink and whether it also uses the mouse to collect ink. See the following table for details.

Value Description
null All attached tablets and the mouse are used to collect ink.
mouse Only the mouse is used to collect ink.
other tablet Only the specified tablet is used to collect ink.

Important Security InformationSecurity Alert: If using under partial trust, this constructor requires UIPermissionWindow.AllWindows Leave Site permission, in addition to the permissions required by RealTimeStylus. See Security And Trust for more information.

Examples

This Microsoft® Visual C#® .NET example is a snippet from a form's Load Leave Site event handler, which creates a RealTimeStylus object attached to the Handle Leave Site of the Panel Leave Site object, thePanel. Only the Tablet object, theTablet, is used for input.

[C#]<![CDATA[using Microsoft.Ink;
using Microsoft.StylusInput;
using Microsoft.StylusInput.PluginData;

// ...

// The panel where the tablet pen data is collected.
private System.Windows.Forms.Panel thePanel;

// The form's Load event handler.
private void theForm_Load(object sender, System.EventArgs e)
{
    // ...

    // Create the RealTimeStylus object.
    this.theRealTimeStylus = new RealTimeStylus(this.thePanel.Handle, theTablet);

    // ...
}

See Also