Export (0) Print
Expand All

RealTimeStylus.GetTabletContextIdFromTablet Method

Returns the tablet context identifer that is associated with a given Tablet object.

Namespace:  Microsoft.StylusInput
Assembly:  Microsoft.Ink (in Microsoft.Ink.dll)

public int GetTabletContextIdFromTablet(
	Tablet tablet
)

Parameters

tablet
Type: Microsoft.Ink.Tablet

The Tablet object.

Return Value

Type: System.Int32
The tablet context identifer that is associated with the given Tablet object.

NoteNote:

A tablet context identifier is specific to RealTimeStylus object; however two RealTimeStylus objects may have a different context identifiers for the same Tablet object. In addition, a tablet context identifier is only valid while a RealTimeStylus object is enabled. If a RealTimeStylus object is disabled and then re-enabled, the tablet context identifier for each Tablet object may have a different value from when the RealTimeStylus object was first enabled.

This method throws an exception when the RealTimeStylus is disabled or disposed or when the tablet parameter is null (Nothing in Visual Basic).

NoteNote:

This function can be re-entered when called within certain message handlers, causing unexpected results. Take care to avoid a reentrant call when handling any of the following messages: WM_ACTIVATE, WM_ACTIVATEAPP, WM_NCACTIVATE, WM_PAINT; WM_SYSCOMMAND if wParam is set to SC_HOTKEY or SC_TASKLIST; and WM_SYSKEYDOWN (when processing Alt-Tab or Alt-Esc key combinations). This is an issue with single-threaded apartment model applications.

This C# example is a snippet from the implementation of the IStylusAsyncPlugin interface's TabletAdded method. The form which implements the IStylusAsyncPlugin interface contains a TextBox object, theTextBox. The TabletAdded method displays information about the tablet that was added, calls the GetTabletContextIdFromTablet method to get the tablet's context identifier, and calls the GetTabletPropertyDescriptionCollection method to get the list of packet properties supported by the tablet.

using Microsoft.Ink;
using Microsoft.StylusInput;
using Microsoft.StylusInput.PluginData;

// ...

// Declare the RealTimeStylus objects, the GestureRecognizer plugin,
// and the DynamicRenderer plug-in.
private Microsoft.StylusInput.RealTimeStylus thePrimaryRealTimeStylus = null;
private Microsoft.StylusInput.RealTimeStylus theSecondaryRealTimeStylus = null;
private Microsoft.StylusInput.GestureRecognizer theGestureRecognizer = null;
private Microsoft.StylusInput.DynamicRenderer theDynamicRenderer = null;

// ...

// Called when a tablet is added while the RealTimeStylus is enabled.
public void TabletAdded(RealTimeStylus sender, TabletAddedData data)
{
    // Display information about the tablet that was added.
    int theContextId =
        this.thePrimaryRealTimeStylus.GetTabletContextIdFromTablet(data.Tablet);

    this.theTextBox.Text = string.Format(
        "Tablet added, Name = {0}, ContextId={1}, available packet properties:"
        + Environment.NewLine, data.Tablet.Name, theContextId);

    TabletPropertyDescriptionCollection theTabletProperties =
        this.thePrimaryRealTimeStylus.GetTabletPropertyDescriptionCollection(theContextId);

    foreach(TabletPropertyDescription theTabletPropertyDescription in theTabletProperties)
    {
        // ...
    }
}

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft