PenInputPanel.InputFailed 事件

已否决。在 PenInputPanel 对象尚未将用户输入插入附加控件时更改输入焦点,则会发生此事件。PenInputPanel 已由 Microsoft.Ink.TextInput 替换。

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

语法

声明
Public Event InputFailed As PenInputPanelInputFailedEventHandler
用法
Dim instance As PenInputPanel
Dim handler As PenInputPanelInputFailedEventHandler

AddHandler instance.InputFailed, handler
public event PenInputPanelInputFailedEventHandler InputFailed
public:
 event PenInputPanelInputFailedEventHandler^ InputFailed {
    void add (PenInputPanelInputFailedEventHandler^ value);
    void remove (PenInputPanelInputFailedEventHandler^ value);
}
/** @event */
public void add_InputFailed (PenInputPanelInputFailedEventHandler value)
/** @event */
public void remove_InputFailed (PenInputPanelInputFailedEventHandler value)
JScript 不支持事件。

备注

事件处理程序接收 PenInputPanelInputFailedEventArgs 类型的参数,该参数包含有关此事件的数据。

如果在尚未将用户输入插入附加的控件时输入焦点发生更改,则会发生 InputFailed 事件。例如,如果用户将墨迹 输入到书写板中,然后在识别器来不及完成操作之前点击另一个编辑控件,则会激发该事件。

通过使用传入该事件的窗口句柄,可以选择在发生该事件时手动插入文本。

ms567738.alert_caution(zh-cn,VS.90).gif重要说明:

从 Microsoft(R) Windows(R) XP Tablet PC Edition 2005 开始,不再应用 InputFailed 事件。文本始终在焦点更改之前插入。

ms567738.alert_security(zh-cn,VS.90).gif安全说明:

如果在部分信任环境下使用,则除了 PenInputPanel 所需的权限以外,该事件还需要 SecurityPermissionFlag.AllFlags 权限。请参见Security and Trust

示例

此 C# 示例创建两个 PenInputPanel 对象(thePenInputPanel1 和 thePenInputPanel2),并将它们附加到 TextBox 控件(textBox1 和 textBox2)。此示例向每个 PenInputPanel 对象添加一个 PenInputPanelInputFailedEventHandler (InputFailed_Event)。在事件处理程序中,如果焦点已经更改,则通过设置前一个 TextBox 控件的 Text 属性来设置文本。

//...

// Declare PenInputPanel objects
PenInputPanel thePenInputPanel1;
PenInputPanel thePenInputPanel2;

public Form1()
{
    // Required for Windows Form Designer support
    InitializeComponent();

    // Create, and attach new PenInputPanels to a TextBox controls.
    thePenInputPanel1 = new PenInputPanel(textBox1);
    thePenInputPanel2 = new PenInputPanel(textBox2);

    // Add an InputFailed event handler to each PenInputPanel
    thePenInputPanel1.InputFailed +=
        new PenInputPanelInputFailedEventHandler(InputFailed_Event);

    thePenInputPanel2.InputFailed +=
        new PenInputPanelInputFailedEventHandler(InputFailed_Event);
}

//...

public void InputFailed_Event(object sender,
PenInputPanelInputFailedEventArgs e)
{
    // Make sure the object that generated
    // the event is a PenInputPanel object
    if (sender is PenInputPanel)
    {
        PenInputPanel theSenderPanel = (PenInputPanel)sender;

        // Set the text in the previous control
        theSenderPanel.AttachedEditControl.Text += e.Text;
    }
}

此 Microsoft Visual Basic(R) .NET 示例创建两个 PenInputPanel 对象(thePenInputPanel1 和 thePenInputPanel2),并将它们附加到 TextBox 控件(textBox1 和 textBox2)。此示例向每个 PenInputPanel 对象添加一个 PenInputPanelInputFailedEventHandler (InputFailed_Event)。在事件处理程序中,如果焦点已经更改,则通过设置前一个 TextBox 控件的 Text 属性来设置文本。

'...

' Declare the PenInputPanel objects
Dim thePenInputPanel1 As PenInputPanel
Dim thePenInputPanel2 As PenInputPanel

Public Sub New()
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    ' Create and attach new PenInputPanels to a TextBox controls.
    thePenInputPanel1 = New PenInputPanel(TextBox1)
    thePenInputPanel2 = New PenInputPanel(TextBox2)

    ' Add an InputFailed event handler to each PenInputPanel
    AddHandler thePenInputPanel1.InputFailed, AddressOf InputFailed_Event
    AddHandler thePenInputPanel2.InputFailed, AddressOf InputFailed_Event
End Sub 'New

'...

Public Sub InputFailed_Event(ByVal sender As Object, ByVal e As _
                             PenInputPanelInputFailedEventArgs)
    ' Make sure the object that generated
    ' the event is a PenInputPanel object
    If TypeOf sender Is PenInputPanel Then
        Dim thePenInputPanel As PenInputPanel = CType(sender, PenInputPanel)

        ' Set the text in the previous control
        thePenInputPanel.AttachedEditControl.Text += e.Text
    End If
End Sub 'InputFailed_Event

平台

Windows Vista

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

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

PenInputPanel 类

PenInputPanel 成员

Microsoft.Ink 命名空间

PenInputPanel.OnInputFailed