返回一个对象,该对象实现 System.Collections.IEnumerator 接口并可以循环访问 CursorButtons 集合中的 CursorButton 对象。
命名空间: Microsoft.Ink
程序集: Microsoft.Ink(在 Microsoft.Ink.dll 中)
语法
声明
Public Function GetEnumerator As CursorButtons..::.CursorButtonsEnumerator
用法
Dim instance As CursorButtons
Dim returnValue As CursorButtons..::.CursorButtonsEnumerator
returnValue = instance.GetEnumerator()
public CursorButtons..::.CursorButtonsEnumerator GetEnumerator()
public:
CursorButtons..::.CursorButtonsEnumerator^ GetEnumerator()
public CursorButtons..::.CursorButtonsEnumerator GetEnumerator()
public function GetEnumerator() : CursorButtons..::.CursorButtonsEnumerator
返回值
类型:Microsoft.Ink.CursorButtons.CursorButtonsEnumerator
一个对象,该对象实现 System.Collections.IEnumerator 接口并可以循环访问 CursorButtons 集合中的 CursorButton 对象。
备注
如果在某些消息处理程序内调用此函数,则可以重新进入此函数,从而导致意外的结果。在处理以下任一消息时,请注意避免可重入调用:WM_ACTIVATE、WM_ACTIVATEAPP、WM_NCACTIVATE、WM_PAINT;WM_SYSCOMMAND(如果 wParam 设置为 SC_HOTKEY 或 SC_TASKLIST);以及 WM_SYSKEYDOWN(处理 Alt-Tab 或 Alt-Esc 组合键时)。这是单线程单元模型应用程序的问题。
示例
下面的示例通过两种方式演示如何循环访问 CursorButtons 集合并获取 Cursor 对象 theCursor 中的每个 CursorButton 对象的名称。CursorButtons 集合由 Cursor.Buttons 属性返回。
在此示例中,将获取 CursorButtons 集合的 System.Collections.IEnumerator,并用于枚举该集合的每个项。
Dim names As ArrayList = New ArrayList()
Dim ienum As IEnumerator = cursor.Buttons.GetEnumerator()
ienum.Reset()
While ienum.MoveNext()
Dim theButton As CursorButton = DirectCast(ienum.Current, CursorButton)
names.Add(theButton.Name)
End While
ArrayList names = new ArrayList();
IEnumerator ienum = cursor.Buttons.GetEnumerator();
ienum.Reset();
while (ienum.MoveNext())
{
CursorButton theButton = (CursorButton)ienum.Current;
names.Add(theButton.Name);
}
此示例使用 foreach 语句,该语句调用内部代码中的 GetEnumerator 方法,该方法是编译器为支持此语句而生成的。
Dim names As ArrayList = New ArrayList()
For Each theButton As CursorButton In cursor.Buttons
names.Add(theButton.Name)
Next
ArrayList names = new ArrayList();
foreach (CursorButton theButton in cursor.Buttons)
{
names.Add(theButton.Name);
}
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。
版本信息
.NET Framework
受以下版本支持:3.0