共用方式為


Remove Method [IInkExtendedProperties Interface]

Remove Method [IInkExtendedProperties Interface]

Removes the IInkExtendedProperty object from the IInkExtendedProperties collection.

Declaration

[C++]

HRESULT Remove (
    [in] VARIANT Identifier
);

[Microsoft® Visual Basic® 6.0]

Public Sub Remove( _
    Identifier _
)

Parameters

Identifier

[in] The identifier of the IInkExtendedProperty object to remove from the collection. The identifier can be a globally unique identifier (GUID), an index, or an extended property object.

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

Return Value

HRESULT value Description
S_OK Success.
E_POINTER A parameter contained an invalid pointer.
CO_E_CLASSSTRING Invalid GUID format.
TPC_E_INVALID_PROPERTY Property could not be found (invalid GUID or index).
E_INK_EXCEPTION An exception occurred inside the method.
E_FAIL An unspecified error occurred.
E_INVALIDARG Invalid display handle.
E_UNEXPECTED Unexpected parameter or property type.

Remarks

This method removes only the extended property from a snapshot of, or reference to, the ink data and does not remove the actual ink data.

The Identifier parameter can be a BSTR, a long, or an IDispatch. Use a BSTR for the GUID of the property, a long for the index of the property, and an IDispatch for a reference to a specific property. To specify the GUID of the property when you are using late binding, such as when you dimension a variable as type Object in Visual Basic 6.0 or when you use a scripting language, you must either dimension the argument variable as a String (Visual Basic 6.0), or pass in the argument as a string literal and not use a variable (script).

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

Example

[Visual Basic 6.0]

This Visual Basic 6.0 example demonstrates the use of the Remove method to remove extended properties from a InkStrokes collection.

Option Explicit
Dim WithEvents theInkCollector As InkCollector
Dim theTimeGuid

Private Sub CommandReport_Click()
    Call PopulateList
End Sub

Private Sub CommandRemove_Click()
    'Strip the timestamp property from theStrokes.
    Dim theStrokes As InkStrokes
    Set theStrokes = theInkCollector.Ink.Strokes
    Dim theStroke As IInkStrokeDisp
    For Each theStroke In theStrokes
        'Test for the timestamp property on this stroke.
        If theStroke.ExtendedProperties.DoesPropertyExist(theTimeGuid)_
        Then
            'Strip the data out of this stroke's extended
            'properties list.
            theStroke.ExtendedProperties.Remove theTimeGuid
        End If
    Next
End Sub

Private Sub Form_Load()
    'Add the InkCollector initialization.
    Set theInkCollector = New InkCollector
    theInkCollector.hWnd = Me.hWnd
    theInkCollector.Enabled = True
    ' This GUID constant will be used for the strokes'
    ' timestamp extended property.
    theTimeGuid = "{00000010-0011-0012-0010-000000000000}"
End Sub

Public Sub PopulateList()
    ' Clear the list before repopulating it.
    List1.Clear
    ' Query the InkCollector's Ink for its strokes collection.
    Dim theStrokes As InkStrokes
    Set theStrokes = theInkCollector.Ink.Strokes
    Dim theStroke As IInkStrokeDisp
    For Each theStroke In theStrokes
        ' If the timestamp property exists in this stroke:
        If _
        theStroke.ExtendedProperties.DoesPropertyExist(theTimeGuid) _
        Then
            Dim theTime As String
            ' Get the time data out of this stroke's extended
            ' properties list, using the previously defined
            ' Guid as a key to the required extended property.
            theTime = theStroke.ExtendedProperties(theTimeGuid).Data
            List1.AddItem (theTime)
        End If
    Next
End Sub

Private Sub theInkCollector_Stroke( _
ByVal Cursor As MSINKAUTLib.IInkCursor, _
ByVal Stroke As MSINKAUTLib.IInkStrokeDisp, _
Cancel As Boolean)
    Dim theExtendedProperty As IInkExtendedProperty
    ' Write the current time into each stroke when it is created
    ' using the Guid as a unique retrieval key.
    Set theExtendedProperty = Stroke.ExtendedProperties.Add(theTimeGuid,Now)
End Sub

Applies To