Share via


RealTimeStylus.GetTabletFromTabletContextId Method

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

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

Syntax

'Declaration
Public Function GetTabletFromTabletContextId ( _
    tabletContextId As Integer _
) As Tablet
'Usage
Dim instance As RealTimeStylus 
Dim tabletContextId As Integer 
Dim returnValue As Tablet 

returnValue = instance.GetTabletFromTabletContextId(tabletContextId)
public Tablet GetTabletFromTabletContextId(
    int tabletContextId
)
public:
Tablet^ GetTabletFromTabletContextId(
    int tabletContextId
)
public function GetTabletFromTabletContextId(
    tabletContextId : int
) : Tablet

Parameters

  • tabletContextId
    Type: System.Int32

    The tablet context identifier for which you want the associated Tablet object.

Return Value

Type: Microsoft.Ink.Tablet
The Tablet object that is associated with a given tablet context identifier.

Remarks

Note

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.

Note

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.

Examples

This C# example is a snippet from the implementation of the IStylusAsyncPlugin interface's RealTimeStylusEnabled method. The form which implements the IStylusAsyncPlugin interface contains a TextBox object, theTextBox. The RealTimeStylusEnabled method displays information about the tablets that are available at the time the RealTimeStylus object is enabled.

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 the RealTimeStylus is enabled, or when the plug-in is added to
// a RealTimeStylus that is already enabled.
public void RealTimeStylusEnabled(RealTimeStylus sender,
    RealTimeStylusEnabledData data)
{
    // Display the list of available tablets.
    this.theTextBox.Text = string.Format(
        "RealTimeStylus enabled ({0} tablets attached):" + Environment.NewLine,
        data.Count);
    foreach (int theContextId in data)
    {
        Tablet theTablet =
            this.thePrimaryRealTimeStylus.GetTabletFromTabletContextId(theContextId);

        this.theTextBox.Text += string.Format(
            "  ContextId = {0}, Tablet.Name = {1}" + Environment.NewLine,
            theContextId, theTablet.Name);

        this.theTextBox.Text += "   Available packet properties:" + Environment.NewLine;

        foreach(TabletPropertyDescription theTabletPropertyDescription in
            this.thePrimaryRealTimeStylus.GetTabletPropertyDescriptionCollection(theContextId))
        {
            this.theTextBox.Text += string.Format("    {0}" + Environment.NewLine,
                this.GetPacketPropertyNameFromGuid(theTabletPropertyDescription.PacketPropertyId));
        }
    }
}

Platforms

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.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

RealTimeStylus Class

RealTimeStylus Members

Microsoft.StylusInput Namespace

Stylus.TabletContextId

RealTimeStylus.GetTabletContextIdFromTablet