次の方法で共有


InkAdded Event

InkAdded Event

Occurs when a stroke is added to the InkDisp object.

Declaration

[C++]

void InkAdded([in] VARIANT StrokeIds);

[Microsoft® Visual Basic® 6.0]

Public Event InkAdded(StrokeIds)

Parameters

StrokeIds

[in] The integer array of stroke ID information for all of the strokes that have been added when this event occurs.

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

Remarks

If you use the InkOverlay object or the InkPicture control (where EditingMode equals Delete and EraserMode equals StrokeErase) and pass the eraser over a stroke, you get the following sequence of events:

The additional InkAdded and InkDeleted events occur because the underlying code adds an internal, invisible stroke to track the eraser.

This event method is defined in the _IInkEvents interface. The _IInkEvents interface implements the IDispatch Leave Site interface with an identifier of DISPID_IEInkAdded.

The InkAdded 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.

Example

[Visual Basic 6.0]

This Visual Basic 6.0 example demonstrates adding an InkAdded event handler to an InkDisp object. Certain strokes are deleted as soon as they are created, if they have more than two self intersections, to demonstrate the InkDeleted event. The event handler writes information about the added strokes to a list box (List1).

Option Explicit
Dim WithEvents theInkCollector As InkCollector
Dim WithEvents theInk As InkDisp

Private Sub Form_Load()
    Set theInkCollector = New InkCollector
    Set theInk = theInkCollector.Ink
    theInkCollector.hWnd = Me.hWnd
    theInkCollector.Enabled = True
End Sub

Private Sub theInkCollector_Stroke( _
ByVal Cursor As MSINKAUTLib.IInkCursor, _
ByVal Stroke As MSINKAUTLib.IInkStrokeDisp, _
Cancel As Boolean)
    If UBound(Stroke.SelfIntersections) > 2 Then
        theInkCollector.Ink.DeleteStroke Stroke
    End If
End Sub

Private Sub theInkCollector_InkAdded(ByVal StrokeIds As Variant)
    Dim theStrokeId As Variant
    For Each theStrokeId In StrokeIds
        List1.AddItem "Added Stroke ID " & theStrokeId
    Next
End Sub

Private Sub theInk_InkDeleted(ByVal StrokeIds As Variant)
    Dim theStrokeId As Variant
    For Each theStrokeId In StrokeIds
        List1.AddItem "Deleted Stroke ID " & theStrokeId
    Next
    Me.Refresh
End Sub

Applies To