共用方式為


InkOverlay.AttachMode Property

InkOverlay.AttachMode Property

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

Definition

Visual Basic .NET Public Property AttachMode As InkOverlayAttachMode
C# public InkOverlayAttachMode AttachMode { get; set; }
Managed C++ public: __property InkOverlayAttachMode* get_AttachMode();
public: __property void set_AttachMode(InkOverlayAttachMode*);

Property Value

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

This property is read/write. This property has no default value.

Behind0 Attaches the new InkOverlay object behind the active window.
InFront1 Attaches the new InkOverlay object in front of the active window.

Exceptions

COMException Leave Site:
ObjectDisposedException Leave Site:

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 InkOverlayAttachMode property and re-enable the object by setting the Enabled property to true.

To repaint a stroke in the InkOverlay object when it is attached in in front of the known window, call the form's Invalidate(rect, true) Leave Site overload, which forces all child controls to repaint.

Caution: If AttachMode is set to InFront and then a control is added to the InkOverlay's AttachedControl, then you will have to re-attach the control. First set Enabled to false, then set the AttachedControl property, and then set Enabled to true.

Examples

[C#]

This C# example creates an InkOverlay object, theInkOverlay and attaches it to a Panel Leave Site, thePanel, on a windows form. Then, the AttachMode property is used to enable and disable inking on top of a Label Leave Site control, theLabel, that is on the panel.

using System;
using System.Windows.Forms;
using Microsoft.Ink;


public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel thePanel;
  private System.Windows.Forms.CheckBox theCheckBox;
  private System.Windows.Forms.Label theLabel;
  private Microsoft.Ink.InkOverlay theInkOverlay;

  // Windows Form Designer generated code
  // . . .

  public Form1()
  {
    theInkOverlay = new Microsoft.Ink.InkOverlay();
    theInkOverlay.Handle = thePanel.Handle;
    theInkOverlay.Enabled = true;
  }

  // Toggle AttachMode between InFront and Behind.
  private void theCheckBox_CheckedChanged(object sender, System.EventArgs e)
  {
    theInkOverlay.Enabled = false;
    if (theInkOverlay.AttachMode == InkOverlayAttachMode.InFront)
    {
      theInkOverlay.AttachMode = InkOverlayAttachMode.Behind;
    }
    else
    {
      theInkOverlay.AttachMode = InkOverlayAttachMode.InFront;
    }
    theInkOverlay.Enabled = true;
  }

}
      

[VB.NET]

This Microsoft® Visual Basic® .NET example creates an InkOverlay object, theInkOverlay and attaches it to a Panel Leave Site, thePanel, on a windows form. Then, the AttachMode property is used to enable and disable inking on top of a Label Leave Site control, theLabel that is on the panel.

Imports Microsoft.Ink

Public Class Form1
    Inherits System.Windows.Forms.Form

    'Windows Form Designer generated code
    '. . .

    Private WithEvents theInkOverlay As Microsoft.Ink.InkOverlay
    Friend WithEvents thePanel As System.Windows.Forms.Panel
    Friend WithEvents theCheckBox As System.Windows.Forms.CheckBox

  Public Sub New()
        MyBase.New()

        theInkOverlay = New Microsoft.Ink.InkOverlay()
        theInkOverlay.Handle = thePanel.Handle
        theInkOverlay.Enabled = True
    End Sub

'. . .

    Private Sub theCheckBox_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles theCheckBox.CheckedChanged
        theInkOverlay.Enabled = False

        If theInkOverlay.AttachMode = InkOverlayAttachMode.Behind Then
            theInkOverlay.AttachMode = InkOverlayAttachMode.InFront
        Else
            theInkOverlay.AttachMode = InkOverlayAttachMode.Behind
        End If

        theInkOverlay.Enabled = True
    End Sub
End Class