SetRectangle Method (Automation Only)

SetRectangle Method (Automation Only)

Sets the elements of the InkRectangle object in a single call.

Declaration

[C++]

        HRESULT SetRectangle (
    [in] long Top,
    [in] long Left,
    [in] long Bottom,
    [in] long Right
);
      

[Microsoft® Visual Basic® 6.0]

        Public Sub SetRectangle( _
    Top As Long, _
    Left As Long, _
    Bottom As Long, _
    Right As Long _
)
      

Parameters

Top

[in] The top of the rectangle.

Left

[in] The left of the rectangle.

Bottom

[in] The bottom of the rectangle.

Right

[in] The right of the rectangle.

Return Value

HRESULT value Description
S_OK Success.
E_POINTER A parameter contained an invalid pointer.
E_INK_EXCEPTION An exception occurred inside the method.

Remarks

Note: The order of the parameters in this method (Top, Left, Bottom, and Right) is different from the expected order (Left, Top, Right, and Bottom).

Example

[Visual Basic 6.0]

This Visual Basic 6.0 example draws a rectangle on the form with a red outline when the packets in the NewPackets event 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 theInkRect As InkRectangle

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

Private Sub theInkCollector_NewPackets( _
ByVal Cursor As MSINKAUTLib.IInkCursor, _
ByVal Stroke As MSINKAUTLib.IInkStrokeDisp, _
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 theInkRect.Left < packetX And theInkRect.Right > packetX And _
    theInkRect.Top < packetY And theInkRect.Bottom > packetY Then
        Form1.Line (theInkRect.Left, theInkRect.Top)-(theInkRect.Right, _
            theInkRect.Bottom), RGB(255, 0, 0), B
    Else
        Form1.Line (theInkRect.Left, theInkRect.Top)-(theInkRect.Right, _
            theInkRect.Bottom), RGB(0, 0, 0), B
    End If
End Sub
      

Applies To