Compartir a través de


PixelToInkSpace Method

PixelToInkSpace Method

Converts a location in pixel space coordinates to be a location in ink space coordinates.

Declaration

[C++]

HRESULT PixelToInkSpace (
    [in] long hdcDisplay,
    [in,out] long* x,
    [in,out] long* y
);

[Microsoft® Visual Basic® 6.0]

Public Sub PixelToInkSpace( _
    hdcDisplay As Long, _
    x As Long, _
    y As Long _
)

Parameters

hdcDisplay

[in] The handle of the device context for the containing control or form.

x

[in, out] The x coordinate of the point to convert into an ink location.

y

[in, out] The y coordinate of the point to convert into an ink location.

Return Value

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

Remarks

PixelToInkSpace converts from pixel to ink space (1 ink unit = .01mm), applies the inverse of the view transform, and then applies the object transform.

Example

[Visual Basic 6.0]

This Visual Basic 6.0 example function DeleteStrokesOnLeft deletes all of the strokes in the InkCollector object passed in that are to the left of the left parameter in pixel space and returns a count of the deleted strokes.

Option Explicit
Dim theInkCollector As InkCollector

Private Sub Command1_Click()
    Dim countOfDeletedStrokes As Long
    countOfDeletedStrokes = DeleteStrokesOnLeft(200, theInkCollector, Form1.hDC)
    Text1.Text = "Deleted " & countOfDeletedStrokes & " strokes"
    Form1.Refresh
End Sub

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

Public Function DeleteStrokesOnLeft( _
ByVal left As Long, _
ByRef theInkCollector As InkCollector, _
ByVal hDC As Long) _
As Long
    Dim i As Integer
    Dim leftTest As Long
    Dim theStroke As IInkStrokeDisp
    Dim theStrokesToDelete As InkStrokes
    ' convert the left parameter from pixels to ink space
    theInkCollector.Renderer.PixelToInkSpace hDC, left, 0
    Set theStrokesToDelete = theInkCollector.Ink.CreateStrokes()
    For Each theStroke In theInkCollector.Ink.Strokes
        Dim ptStrokePoints As Variant
        ptStrokePoints = theStroke.GetPoints()
        For i = 0 To UBound(ptStrokePoints) Step 2
            leftTest = ptStrokePoints(i)
            'If the stroke has a point left of the cutoff,
            If leftTest < left Then
                ' add it to the deletion list
                theStrokesToDelete.Add theStroke
                Exit For 'and stop processing points
            End If
        Next
    Next
    If 0 < theStrokesToDelete.Count Then
        theInkCollector.Ink.DeleteStrokes theStrokesToDelete
    End If
    DeleteStrokesOnLeft = theStrokesToDelete.Count
End Function

Applies To