Freigeben über


InkOverlay.AttachMode Property

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

Namespace: Microsoft.Ink
Assembly: Microsoft.Ink (in microsoft.ink.dll)

Syntax

'Declaration
Public Property AttachMode As InkOverlayAttachMode
'Usage
Dim instance As InkOverlay
Dim value As InkOverlayAttachMode

value = instance.AttachMode

instance.AttachMode = value
public InkOverlayAttachMode AttachMode { get; set; }
public:
property InkOverlayAttachMode AttachMode {
    InkOverlayAttachMode get ();
    void set (InkOverlayAttachMode value);
}
/** @property */
public InkOverlayAttachMode get_AttachMode ()

/** @property */
public void set_AttachMode (InkOverlayAttachMode value)
public function get AttachMode () : InkOverlayAttachMode

public function set AttachMode (value : InkOverlayAttachMode)
Not applicable.

Property Value

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

Value

Meaning

Behind

The InkOverlay is attached behind the known window. ink is drawn underneath child controls.

InFront

The InkOverlay is attached in front of the known window. ink is drawn on top of child controls.

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)Invalidate(rect, true) overload, which forces all child controls to repaint.

Warning

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.

Example

This C# example creates an InkOverlay object, theInkOverlay and attaches it to a Panel, thePanel, on a windows form. Then, the AttachMode property is used to enable and disable inking on top of a Label 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;
  }

}
      

This Microsoft Visual Basic .NET example creates an InkOverlay object, theInkOverlay and attaches it to a Panel, thePanel, on a windows form. Then, the AttachMode property is used to enable and disable inking on top of a Label 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

      

Platforms

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

InkOverlay Class
InkOverlay Members
Microsoft.Ink Namespace