Share via


InputFailed Event

InputFailed Event

Occurs when input focus changes before the PenInputPanel object was able to insert user input into the attached control.

Declaration

[C++]

HRESULT InputFailed (
    [in] long hWnd,
    [in] long Key,
    [in] BSTR Text,
    [in] short ShiftKey,
);

[Microsoft® Visual Basic® 6.0]

Public Event InputFailed ( _
    hWnd as Long, _
    Key as Long, _
    Text as String, _
    ShiftKey as Integer, _
);

Parameters

hWnd

[in] The window handle of the control that invoked the PenInputPanel object.

Key

[in] The virtual key corresponding to the key pressed.

Text

[in] The string that was to be inserted into the control represented by the hWnd parameter when the InputFailed event fired.

For more information about the BSTR data type, see Using the Automation Library.

ShiftKey

[in] The state of the keyboard modifiers, including SHIFT, CAPS, CTRL, and ALT.

Remarks

The InputFailed event occurs when input focus changes before user input was inserted into the attached control. For example, if the user enters ink into the writing pad, then taps on another edit control before the recognizer has had a chance to finish, this event fires.

Using the window handle passed into this event, you can choose to insert the text yourself when this event occurs.

Example

[Visual Basic 6.0]

This Visual Basic 6 example creates two PenInputPanel objects, thePenInputPanel1 and thePenInputPanel2, and attaches them to TextBox controls, Text1 and Text2. It adds InputFailed event handlers, thePenInputPanel1_InputFailed and thePenInputPanel2_InputFailed, to each PenInputPanel. In each event handler, the text is manually added to the TextBox control's Text property.

' Declare new PenInputPanel objects
Dim WithEvents thePenInputPanel1 As PenInputPanel
Dim WithEvents thePenInputPanel2 As PenInputPanel

Private Sub Form_Load()
  ' Create the PenInputPanels
  Set thePenInputPanel1 = New PenInputPanel
  Set thePenInputPanel2 = New PenInputPanel

  ' Attach the PenInputPanels to TextBox controls
  thePenInputPanel1.AttachedEditWindow = Text1.hWnd
  thePenInputPanel2.AttachedEditWindow = Text2.hWnd

End Sub

Private Sub thePenInputPanel1_InputFailed(ByVal hWnd As _
                                          PenInputPanelLib.LONG_PTR, _
                                          ByVal Key As Long, _
                                          ByVal Text As String, _
                                          ByVal ShiftKey As Integer)
  ' Focus changed before the recognizer was finished so
  ' set the text in the control manually
  Text1.Text = Text1.Text + Text
End Sub

Private Sub thePenInputPanel2_InputFailed(ByVal hWnd As _
                                          PenInputPanelLib.LONG_PTR, _
                                          ByVal Key As Long, _
                                          ByVal Text As String, _
                                          ByVal ShiftKey As Integer)
  ' Focus changed before the recognizer was finished so
  ' set the text in the control manually
  Text2.Text = Text2.Text + Text
End Sub

Applies To