Share via


Cursor.Buttons 属性

获取某个已知 Cursor 上的 CursorButtons 集合。

命名空间:  Microsoft.Ink
程序集:  Microsoft.Ink(在 Microsoft.Ink.dll 中)

语法

声明
Public ReadOnly Property Buttons As CursorButtons
用法
Dim instance As Cursor
Dim value As CursorButtons

value = instance.Buttons
public CursorButtons Buttons { get; }
public:
property CursorButtons^ Buttons {
    CursorButtons^ get ();
}
/** @property */
public CursorButtons get_Buttons()
public function get Buttons () : CursorButtons

属性值

类型:Microsoft.Ink.CursorButtons
某个已知 Cursor 上的 CursorButtons 集合。

备注

对于笔,按钮可能包括书写端、橡皮擦端和笔筒按钮。

备注

如果在某些消息处理程序内调用此函数,则可以重新进入此函数,从而导致意外的结果。在处理以下任一消息时,请注意避免可重入调用:WM_ACTIVATEWM_ACTIVATEAPPWM_NCACTIVATEWM_PAINTWM_SYSCOMMAND(如果 wParam 设置为 SC_HOTKEY 或 SC_TASKLIST);以及 WM_SYSKEYDOWN(处理 Alt-Tab 或 Alt-Esc 组合键时)。这是单线程单元模型应用程序的问题。

示例

此 C# 示例返回一份报告,报告作为参数传入的 InkCollector 对象所遇到的所有光标的属性。

using Microsoft.Ink;
//. . .
public string CursorReport(InkCollector theInkCollector)
{
    string theReport = "The InkCollector has encountered the following cursors so far:" + Environment.NewLine;
    // Get the Cursors collection from the InkCollector
    Microsoft.Ink.Cursors theCursors = theInkCollector.Cursors;
    // Prevent changes to the collection while we iterate over it.
    lock( theCursors.SyncRoot )
    {
        theReport += "Count of cursors: " + theCursors.Count + Environment.NewLine + Environment.NewLine ;
        foreach (Microsoft.Ink.Cursor cursor in theCursors)
        {
            theReport += "Cursor Name: " + cursor.Name + Environment.NewLine;
            theReport += "Cursor ToString: " + cursor.ToString() + Environment.NewLine;
            theReport += "Tablet Name: " + cursor.Tablet.Name  + Environment.NewLine;
            theReport += "Cursor Id: " + cursor.Id.ToString()  + Environment.NewLine;
            theReport += "Cursor is inverted: " + cursor.Inverted.ToString()  + Environment.NewLine;
            theReport += "Cursor Buttons:" + Environment.NewLine;
            foreach (CursorButton button in cursor.Buttons)
            {
                CursorButtonState theState = button.State;
                theReport += "    Button Name: " + button.Name + Environment.NewLine;
                theReport += "    State: " + button.State.ToString() + Environment.NewLine;
                theReport += "    Id: " + button.Id.ToString()  + Environment.NewLine + Environment.NewLine;
            }
        }
    }
    return theReport;
}

此 Microsoft(R) Visual Basic(R) .NET 示例返回一份报告,报告作为参数传入的 InkCollector 对象所遇到的所有光标的属性。

Imports Microsoft.Ink
'. . .
Public Function CursorReport(ByVal theInkCollector As InkCollector) _
    As String
    Dim theReport As String = "The InkCollector has encountered " & _
        "the following cursors so far:" & vbCrLf
    ' Get the Cursors collection from the InkCollector
    Dim theCursors As Cursors = theInkCollector.Cursors
    ' Prevent changes to the collection while we iterate over it.
    SyncLock theCursors.SyncRoot
        theReport &= "Count of cursors: " & theCursors.Count & vbCrLf
        Dim theCursor As Cursor
        For Each theCursor In theCursors
            theReport &= "Cursor Name: " & theCursor.Name & vbCrLf
            theReport &= "Cursor ToString: " & theCursor.ToString() & _
                vbCrLf
            theReport &= "Tablet Name: " & theCursor.Tablet.Name & vbCrLf
            theReport &= "Cursor Id: " & theCursor.Id.ToString() & vbCrLf
            theReport &= "Cursor is inverted: " & _
                theCursor.Inverted.ToString() & vbCrLf
            theReport &= "Cursor Buttons:" & vbCrLf
            Dim theButton As CursorButton
            For Each theButton In theCursor.Buttons
                Dim theState As CursorButtonState = theButton.State
                theReport &= "    Button Name: " & theButton.Name & vbCrLf
                theReport &= "    State: " & _
                    theButton.State.ToString() & vbCrLf
                theReport &= "    Id: " & theButton.Id.ToString() & _
                    vbCrLf & vbCrLf
            Next
        Next
    End SyncLock
    Return theReport
End Function

平台

Windows Vista

.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

Cursor 类

Cursor 成员

Microsoft.Ink 命名空间

CursorButton

CursorButtons