AddStrokesAtRectangle Method

AddStrokesAtRectangle Method

Adds a specified Strokes collection into this InkDisp object at a specified rectangle.

Declaration

[C++]

HRESULT AddStrokesAtRectangle (
    [in] IInkStrokes* strokes,
    [in] IInkRectangle* rectangle
);

[Microsoft® Visual Basic® 6.0]

Public Sub AddStrokesAtRectangle( _
    strokes As InkStrokes, _
    rectangle As InkRectangle _
)

Parameters

strokes

[in] Specifies the strokes to add to the ink. These source strokes are appended to this InkDisp object.

rectangle

[in] Specifies the InkRectangle in ink space coordinates where the strokes are added. A run-time error occurs if the coordinates of the rectangle are {0,0,0,0}.

Return Value

Return Value Description
S_OK Success.
E_POINTER A parameter contained an invalid pointer.
E_FAIL An unspecified error occurred.
E_INK_INCOMPATIBLE_OBJECT A pointer does not point at a valid object.
E_INK_EXCEPTION An exception occurred inside the method.
E_INVALIDARG The rectangle's top and bottom are equal.

Remarks

When inserted, the strokes are scaled from the bounding box of the strokes to the rectangle.

This method can be used to copy strokes within a single InkDisp object. The source ink strokes do not have to come from another InkDisp object.

Examples

[Visual Basic 6.0]

This Visual Basic 6.0 example demonstrates calling the AddStrokesAtRectangle method to copy the ink from the main drawing area in FrameMain to the thumbnail panel, FrameThumb. This sample application began with a simple form and added these two frame objects, as well as a reference to the Tablet PC Type Library. To keep the thumbnail panel up to date, the Stroke event handler is added to the InkCollector named theMainInkCollector. theMainInkCollector is an InkCollector attached to the frame named FrameMain. theThumbnailIC is an InkCollector attached to the frame named FrameThumb.

Dim WithEvents theMainInkCollector As InkCollector
Dim theThumbnailInkCollector As InkCollector

Private Sub Form_Load()
    Set theMainInkCollector = New InkCollector
    theMainInkCollector.hWnd = Me.FrameMain.hWnd
    Set theThumbnailInkCollector = New InkCollector
    theThumbnailInkCollector.hWnd = Me.FrameThumb.hWnd
    theMainInkCollector.Enabled = True
End Sub

Private Sub theMainInkCollector_Stroke( _
ByVal Cursor As MSINKAUTLib.IInkCursor, _
ByVal Stroke As MSINKAUTLib.IInkStrokeDisp, _
Cancel As Boolean)
    'Get the bounding box for the strokes, then scale
    'that by the difference in size between the main panel
    'and the thumbnail panel to get the destination rectangle.
    Dim theBB As InkRectangle
    Set theBB = theMainInkCollector.Ink.Strokes.GetBoundingBox
    Dim theHScale
    Dim theVScale
    theHScale = FrameThumb.Width / FrameMain.Width
    theVScale = FrameThumb.Height / FrameMain.Height
    theBB.Right = theBB.Right * theHScale
    theBB.Bottom = theBB.Bottom * theVScale
    theBB.Left = theBB.Left * theHScale
    theBB.Top = theBB.Top * theVScale
    'Delete the old strokes in the thumbnail, and add the new.
    theThumbnailInkCollector.Ink.DeleteStrokes
    theThumbnailInkCollector.Ink.AddStrokesAtRectangle theMainInkCollector.Ink.Strokes, theBB
    FrameThumb.Refresh
End Sub

Applies To