Share via


AttachMode Property

AttachMode Property

Gets or sets the value that specifies whether the InkOverlay object is attached behind or in front of the known window.

Declaration

[C++]

[propput] HRESULT put_AttachMode ([in] InkOverlayAttachMode AttachMode);
[propget] HRESULT get_AttachMode ([out, retval] InkOverlayAttachMode*
    AttachMode);

[Microsoft® Visual Basic® 6.0]

Public Property Get AttachMode() As InkOverlayAttachMode
Public Property Let AttachMode(ByVal theMode As InkOverlayAttachMode)

Property Value

InkOverlayAttachMode The value that specifies whether the InkOverlay object is attached behind or in front of the known window.

This property is read/write.

Behind Default. The InkOverlay object is attached behind the known window.
InFront The InkOverlay object is attached in front of the known window.

Remarks

Note: An error occurs if the InkOverlay object is not disabled before setting this property. To disable the InkOverlay object, set the Enabled property to FALSE. You can then set the AttachMode property and re-enable the object by setting the Enabled property to TRUE.

Caution: If AttachMode is set to InFront and then a control is added to the InkOverlay's attached control, then you will have to reset the InkOverlay's hWnd. First set Enabled to FALSE, then set the hWnd property, and then set Enabled to TRUE.

Example

[Visual Basic 6.0]

This Visual Basic 6.0 example demonstrates setting the AttachMode property and using the HitTestSelection method. This application uses a check box, CheckSelectionMode to toggle an InkOverlay object between Inking and Selection modes, and uses the HitTestSelection results to change the color of the selection when one of the selection handles of the selection rectangle is clicked.

Option Explicit
Private WithEvents theInkOverlay As InkOverlay

Private Sub CheckSelectionMode_Click()
    'Toggle the EditingMode between Inking and Selection
    If theInkOverlay.EditingMode = IOEM_Ink Then
        theInkOverlay.EditingMode = IOEM_Select
    Else
        theInkOverlay.EditingMode = IOEM_Ink
    End If
End Sub

Private Sub Form_Load()
    Me.ScaleMode = vbPixels
    Set theInkOverlay = New InkOverlay
    theInkOverlay.hWnd = Me.hWnd
    theInkOverlay.AttachMode = IOAM_Behind
    theInkOverlay.Enabled = True
End Sub

Private Sub Form_MouseDown( _
Button As Integer, Shift As Integer, X As Single, Y As Single)
    If theInkOverlay.EditingMode = IOEM_Select Then
        Dim result As SelectionHitResult
        result = theInkOverlay.HitTestSelection(X, Y)
        Dim theDrawingAttributes As New InkDrawingAttributes
        If result = SHR_NW Then
            theDrawingAttributes.Color = vbGreen
        ElseIf result = SHR_NE Then
            theDrawingAttributes.Color = vbRed
        ElseIf result = SHR_SE Then
            theDrawingAttributes.Color = vbYellow
        ElseIf result = SHR_SW Then
            theDrawingAttributes.Color = vbBlue
        End If
        theInkOverlay.Selection.ModifyDrawingAttributes theDrawingAttributes
        Refresh
    End If
End Sub

Applies To