次の方法で共有


SystemGesture Event

SystemGesture Event

Occurs when a system gesture is recognized.

Declaration

[C++]

void SystemGesture(
    [in] IInkCursor* Cursor,
    [in] InkSystemGesture Id,
    [in] long X,
    [in] long Y,
    [in] long Modifier,
    [in] BSTR Character,
    [in] long CursorMode
);

[Microsoft® Visual Basic® 6.0]

Public Event SystemGesture( _
    Cursor As IInkCursor, _
    Id As InkSystemGesture, _
    X As Long, _
    Y As Long, _
    Modifier As Long, _
    Character As String, _
    CursorMode As Long _
)

Parameters

Cursor

[in] The IInkCursor object that generated the SystemGesture event.

Id

[in] The value of the system gesture.

X

[in] The x-coordinate of the location of the gesture.

Y

[in] The y-coordinate of the location of the gesture.

Modifier

[in] Reserved.

Character

[in] Reserved.

CursorMode

[in] A value that indicates whether the IInkCursor object is in normal mode or eraser mode. 1 is for normal mode and 2 is for eraser mode.

Remarks

System gestures are useful because they give information about the IInkCursor object that is being used to create the gesture. They also provide shortcuts to combinations of mouse events and are "cheaper" ways to detect mouse events.

For example, instead of looking for a MouseUp/MouseDown pair of events with no other mouse events occurring in between, you can look for the Tap or RightTap system gestures.

As another example, instead of listening for MouseDown/ MouseMove events and getting numerous MouseMove messages, you can watch for the Drag or RightDrag system gestures as long as you're not interested in the (x, y) coordinates of every position of the mouse. This allows you to receive only one message instead of numerous MouseMove messages.

For a list of specific system gestures, see the InkSystemGesture enumeration type. For more information about system gestures, see Making Windows Work with a Pen.

This event method is defined in the _IInkCollectorEvents, _IInkOverlayEvents, and _IInkPictureEvents dispatch-only interfaces (dispinterfaces) with an ID of DISPID_ICESystemGesture.

Example

[Visual Basic 6.0]

This Visual Basic 6.0 example displays application and system gesture event information in a multiline text edit control, Text1, on the main form window.

Option Explicit
Dim WithEvents theInkCollector As InkCollector

Private Sub Form_Load()
    Set theInkCollector = New InkCollector
    theInkCollector.hWnd = Me.hWnd
    'Set the ink collection mode to collect ink and gestures,
    'and turn off all application gestures except the chevrons.
    theInkCollector.CollectionMode = ICM_InkAndGesture
    theInkCollector.SetGestureStatus IAG_AllGestures, False
    theInkCollector.SetGestureStatus IAG_ChevronUp, True
    theInkCollector.SetGestureStatus IAG_ChevronDown, True
    theInkCollector.SetGestureStatus IAG_ChevronLeft, True
    theInkCollector.SetGestureStatus IAG_ChevronRight, True
    theInkCollector.Enabled = True
    theInkCollector.SetEventInterest ICEI_SystemGesture, True
End Sub

Private Sub theInkCollector_Gesture( _
ByVal Cursor As MSINKAUTLib.IInkCursor, _
ByVal Strokes As MSINKAUTLib.InkStrokes, _
ByVal Gestures As Variant, _
Cancel As Boolean)
    Dim theGesture As Variant
    Dim X As Long
    Dim Y As Long
    Text1.Text = ""
    For Each theGesture In Gestures
        theGesture.GetHotPoint X, Y
        Text1.Text = Text1.Text & "Gesture " & _
        AppGestureName(theGesture.Id) & _
        " at (" & X & "," & Y & ") confidence: " & _
        ConfidenceName(theGesture.Confidence) & vbCrLf
    Next
End Sub

Private Sub theInkCollector_SystemGesture( _
ByVal Cursor As MSINKAUTLib.IInkCursor, _
ByVal Id As MSINKAUTLib.InkSystemGesture, _
ByVal X As Long, ByVal Y As Long, _
ByVal Modifier As Long, _
ByVal Character As String, _
ByVal CursorMode As Long)
    Text1.Text = "SystemGesture " & _
    SystemGestureName(Id) & " (x:" & X & ",y:" & Y & ")"
End Sub

Private Function SystemGestureName(ByVal Id As InkSystemGesture) As String
    Select Case Id
        Case ISG_DoubleTap
            SystemGestureName = "ISG_DoubleTap"
        Case ISG_Drag
            SystemGestureName = "ISG_Drag"
        Case ISG_HoldEnter
            SystemGestureName = "ISG_HoldEnter"
        Case ISG_HoldLeave
            SystemGestureName = "ISG_HoldLeave"
        Case ISG_HoverEnter
            SystemGestureName = "ISG_HoverEnter"
        Case ISG_HoverLeave
            SystemGestureName = "ISG_HoverLeave"
        Case ISG_RightDrag
            SystemGestureName = "ISG_RightDrag"
        Case ISG_RightTap
            SystemGestureName = "ISG_RightTap"
        Case ISG_Tap
            SystemGestureName = "ISG_Tap"
        Case Else
            SystemGestureName = "SystemGesture(" & Id & ")"
    End Select
End Function

Private Function AppGestureName(ByVal Id As InkApplicationGesture) _
As String
    Select Case Id
        Case IAG_AllGestures
            AppGestureName = "IAG_AllGestures"
        Case IAG_NoGesture
            AppGestureName = "IAG_NoGesture"
        Case IAG_ChevronUp
            AppGestureName = "IAG_ChevronUp"
        Case IAG_ChevronDown
            AppGestureName = "IAG_ChevronDown"
        Case IAG_ChevronLeft
            AppGestureName = "IAG_ChevronLeft"
        Case IAG_ChevronRight
            AppGestureName = "IAG_ChevronRight"
        Case Else
            AppGestureName = "AppGesture(" & Id & ")"
    End Select
End Function

Private Function ConfidenceName(ByVal Id As InkRecognitionConfidence) _
As String
    Select Case Id
        Case IRC_Strong
            ConfidenceName = "IRC_Strong"
        Case IRC_Intermediate
            ConfidenceName = "IRC_Intermediate"
        Case IRC_Poor
            ConfidenceName = "IRC_Poor"
        Case Else
            ConfidenceName = "Confidence(" & Id & ")"
    End Select
End Function

Applies To