RealTimeStylus.GetTabletFromTabletContextId 方法

返回与给定的 Tablet 上下文标识符关联的 Tablet 对象。

命名空间:  Microsoft.StylusInput
程序集:  Microsoft.Ink(在 Microsoft.Ink.dll 中)

语法

声明
Public Function GetTabletFromTabletContextId ( _
    tabletContextId As Integer _
) As Tablet
用法
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 Tablet GetTabletFromTabletContextId(
    int tabletContextId
)
public function GetTabletFromTabletContextId(
    tabletContextId : int
) : Tablet

参数

  • tabletContextId
    类型:System.Int32
    希望与 Tablet 对象关联的 Tablet 上下文标识符。

返回值

类型:Microsoft.Ink.Tablet
与给定的 Tablet 上下文标识符关联的 Tablet 对象。

备注

备注

Tablet 上下文标识符特定于 RealTimeStylus 对象,但是两个 RealTimeStylus 对象可能对同一个 Tablet 对象具有不同的上下文标识符。并且,仅当启用 RealTimeStylus 对象时 Tablet 上下文标识符才有效。如果先禁用然后重新启用 RealTimeStylus 对象,则每个 Tablet 对象的 Tablet 上下文标识符的值可能与第一次启用 RealTimeStylus 对象时不同。

当禁用或释放 RealTimeStylus 时此方法将引发异常。

备注

当在某些消息处理程序内调用此函数时可以重新进入此函数,并导致意外结果。在处理以下任一消息时,请注意避免可重入调用:WM_ACTIVATEWM_ACTIVATEAPPWM_NCACTIVATEWM_PAINTWM_SYSCOMMAND(如果 wParam 设置为 SC_HOTKEY 或 SC_TASKLIST);以及 WM_SYSKEYDOWN(处理 Alt-Tab 或 Alt-Esc 组合键时)。这是单线程单元模型应用程序的问题。

示例

此 C# 示例是 IStylusAsyncPlugin 接口的 RealTimeStylusEnabled 方法实现中的代码段。实现 IStylusAsyncPlugin 接口的窗体包含一个 TextBox 对象 theTextBox。RealTimeStylusEnabled 方法可以显示有关在 RealTimeStylus 对象启用时可用的 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 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));
        }
    }
}

平台

Windows Vista, Windows XP SP2, Windows Server 2003

.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

RealTimeStylus 类

RealTimeStylus 成员

Microsoft.StylusInput 命名空间

Stylus.TabletContextId

RealTimeStylus.GetTabletContextIdFromTablet