Imports Microsoft.Ink Public Class Form1 Private WithEvents obj As InkOverlay Private Sub obj_NewInAirPackets(ByVal sender As Object, _ ByVal e As InkCollectorNewInAirPacketsEventArgs) Handles obj.NewInAirPackets Dim pos As New Point(e.PacketData(0), e.PacketData(1)) Label1.Text = String.Format("{0} [空中] {1}", e.Cursor.Name, pos) End Sub Private Sub obj_NewPackets(ByVal sender As Object, _ ByVal e As InkCollectorNewPacketsEventArgs) Handles obj.NewPackets Dim pos As New Point(e.PacketData(0), e.PacketData(1)) Dim pressure As Integer = e.PacketData(2) Label1.Text = String.Format("{0} [筆圧{1}] {2}", e.Cursor.Name, pressure, pos) End Sub Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load obj = New InkOverlay() obj.AttachedControl = Me 'Form を対象にして認識させる obj.AttachMode = InkOverlayAttachMode.Behind 'Form 上の Label や Button 等の下のレイヤー 'パケットに筆圧を含める Dim Packets() As Guid = {PacketProperty.NormalPressure} obj.DesiredPacketDescription = Packets 'スタイラスの動きを分かりやすくするため、デジタルインクをあえて描画させておく '邪魔にならない程度に目立たせるため、半透明の赤いインクを利用 obj.DynamicRendering = True obj.EditingMode = InkOverlayEditingMode.Ink obj.DefaultDrawingAttributes.Color = Color.Red obj.DefaultDrawingAttributes.Transparency = 200 obj.Enabled = True 'タブレット利用=On End Sub Private Sub Form1_FormClosed(ByVal sender As Object, _ ByVal e As FormClosedEventArgs) Handles Me.FormClosed obj.Dispose() '使用後は必ず破棄すること End Sub Private Sub obj_Stroke(ByVal sender As Object, _ ByVal e As InkCollectorStrokeEventArgs) Handles obj.Stroke e.Cancel = True '描画したいわけではないので、インク情報は即座に捨ててしまう End Sub End Class