Compartilhar via


SelectionChanging Event

SelectionChanging Event

Occurs when the selection of ink within the control is about to change, such as through alterations to the user interface, cut-and-paste procedures, or the Selection property.

Declaration

[C++]

void SelectionChanging([in] IInkStrokes* NewSelection);

[Microsoft® Visual Basic® 6.0]

Public Event SelectionChanging(NewSelection As InkStrokes)

Parameters

NewSelection

[in] The new collection of InkStrokes that is being selected.

Remarks

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

Example

[Visual Basic 6.0]

This Visual Basic 6.0 example demonstrates adding a SelectionChanged and a SelectionChanging event handler to an InkOverlay object. These events are initiated with a command button, Command1, which randomly selects one third of the strokes collected in the InkOverlay object. The SelectionChanging event handler is invoked before the event begins, and causes the Color and Width drawing attributes to be randomized before the selection is painted. The SelectionChanged event handler writes information about the number of times the event has occurred in a text box, Text1.

Option Explicit
Dim WithEvents theInkOverlay As InkOverlay
Dim countChanges As Integer

Private Sub Command1_Click()
    Dim theStrokes As InkStrokes
    Dim i As Long
    Set theStrokes = theInkOverlay.Ink.CreateStrokes
    For i = Int(3 * Rnd) To theInkOverlay.Ink.Strokes.Count - 1 Step 3
        theStrokes.Add theInkOverlay.Ink.Strokes.Item(i)
    Next
    theInkOverlay.Selection = theStrokes
End Sub

Private Sub Form_Load()
    Randomize
    Set theInkOverlay = New InkOverlay
    theInkOverlay.hWnd = Me.hWnd
    theInkOverlay.Enabled = True
    countChanges = 0
End Sub

Private Sub theInkOverlay_SelectionChanged()
    Text1.Text = "InkOverlay selection changed " _
        & countChanges & " times."
    countChanges = countChanges + 1
End Sub

Private Sub theInkOverlay_SelectionChanging( _
ByVal NewSelection As MSINKAUTLib.IInkStrokes)
    Dim theDrawingAttributes As New InkDrawingAttributes
    theDrawingAttributes.Color = RGB(Int(255 * Rnd), Int(255 * Rnd), Int(255 * Rnd))
    theDrawingAttributes.Width = Int(240 * Rnd) + 30
    NewSelection.ModifyDrawingAttributes theDrawingAttributes
End Sub

Applies To