Compartilhar via


NewInAirPackets Event

NewInAirPackets Event

Occurs when an in-air packet is seen.

Declaration

[C++]

void NewInAirPackets(
    [in] IInkCursor* Cursor,
    [in] long PacketCount,
    [in, out] VARIANT* PacketData
);

[Microsoft® Visual Basic® 6.0]

Public Event NewInAirPackets( _
    Cursor As IInkCursor, _
    PacketCount As Long, _
    PacketData _
)

Parameters

Cursor

[in] The IInkCursor object that generated the NewInAirPackets event.

PacketCount

[in] The number of in-air packets received.

PacketData

[in, out] An array that contains the selected data for the packet.

For more information about the VARIANT structure, see Using the Automation Library.

Remarks

An in-air packet is created when a user moves a pen near the tablet and the cursor is within the ink collector object's window or the user moves a mouse within the ink collector object's associated window. NewInAirPackets events are generated rapidly, and the event handler must be fast or performance suffers.

This event method is defined in the _IInkCollectorEvents, _IInkOverlayEvents, and _IInkPictureEvents dispatch-only interfaces (dispinterfaces) with an ID of DISPID_ICENewInAirPackets.

The NewInAirPackets event is fired even when in select or erase mode, not just when inserting ink. This requires that you monitor the editing mode (which you are responsible for setting) and be aware of the mode before interpreting the event. The advantage of this requirement is greater freedom to innovate on the platform through greater awareness of platform events.

To set which properties are contained in this array, use the DesiredPacketDescription property of the ink collector object. The array that the PacketData parameter returns contains the data for those properties.

Note: Although you can modify the packet data, these modifications are not persisted or used.

Example

[Visual Basic 6.0]

This Visual Basic 6.0 example draws a rectangle on the form with a red outline when the in-air packets are within the rectangle or with a black outline when the packets are outside the rectangle. This demonstrates how to use the packet events to control application behaviors.

Option Explicit
Dim WithEvents theInkCollector As InkCollector
Dim theInkRectangle As InkRectangle

Private Sub Form_Load()
    Set theInkCollector = New InkCollector
    theInkCollector.hWnd = Me.hWnd
    theInkCollector.Enabled = True
    Set theInkRectangle = New InkRectangle
    theInkRectangle.SetRectangle 40, 40, 120, 300
    ScaleMode = vbPixels
    Form1.Line (theInkRectangle.Left, theInkRectangle.Top)-(theInkRectangle.Right, _
        theInkRectangle.Bottom), RGB(0, 0, 0), B
    theInkCollector.SetEventInterest ICEI_NewInAirPackets, True
End Sub

Private Sub theInkCollector_NewInAirPackets( _
ByVal Cursor As MSINKAUTLib.IInkCursor, _
ByVal PacketCount As Long, PacketData As Variant)
    Dim packetX As Long
    Dim packetY As Long
    'There may be multiple packets of data, but we will rely on
    'the fact that there will be at least one, and its first two
    'data items are the X and Y coordinates.
    packetX = PacketData(0)
    packetY = PacketData(1)
    theInkCollector.Renderer.InkSpaceToPixel Form1.hDC, packetX, packetY
    'Draw the box in red if the packets are within it, and black if not.
    If theInkRectangle.Left < packetX And theInkRectangle.Right > packetX And _
        theInkRectangle.Top < packetY And theInkRectangle.Bottom > packetY Then
        Form1.Line (theInkRectangle.Left, theInkRectangle.Top)-(theInkRectangle.Right, _
            theInkRectangle.Bottom), RGB(255, 0, 0), B
    Else
        Form1.Line (theInkRectangle.Left, theInkRectangle.Top)-(theInkRectangle.Right, _
            theInkRectangle.Bottom), RGB(0, 0, 0), B
    End If
End Sub

Applies To