Share via


CursorButtons.GetEnumerator Method

Returns an object that implements the System.Collections.IEnumerator interface and that can iterate through the CursorButton objects within the CursorButtons collection.

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

Syntax

'Declaration
Public Function GetEnumerator As CursorButtons.CursorButtonsEnumerator
'Usage
Dim instance As CursorButtons 
Dim returnValue As CursorButtons.CursorButtonsEnumerator 

returnValue = instance.GetEnumerator()
public CursorButtons.CursorButtonsEnumerator GetEnumerator()
public:
CursorButtons.CursorButtonsEnumerator^ GetEnumerator()
public function GetEnumerator() : CursorButtons.CursorButtonsEnumerator

Return Value

Type: Microsoft.Ink.CursorButtons.CursorButtonsEnumerator
An object that implements the System.Collections.IEnumerator interface and that can iterate through the CursorButton objects within the CursorButtons collection.

Remarks

This function can be re-entered if called within certain message handlers, causing unexpected results. Take care to avoid a reentrant call when handling any of the following messages: WM_ACTIVATE, WM_ACTIVATEAPP, WM_NCACTIVATE, WM_PAINT; WM_SYSCOMMAND if wParam is set to SC_HOTKEY or SC_TASKLIST; and WM_SYSKEYDOWN (when processing Alt-Tab or Alt-Esc key combinations). This is an issue with single-threaded apartment model applications.

Examples

These examples show two ways to iterate over the CursorButtons collection and get the name for each CursorButton object in the Cursor object, theCursor. The CursorButtons collection is returned by the Cursor.Buttons property.

In this example, the System.Collections.IEnumerator is obtained for the CursorButtons collection, and used to enumerate each item of the collection.

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);
}

This example uses the foreach statement which calls the GetEnumerator method in internal code that the compiler generates to support the statement.

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);
}

Platforms

Windows 7, Windows Vista, Windows Server 2008 R2, Windows Server 2008

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

CursorButtons Class

CursorButtons Members

Microsoft.Ink Namespace

CursorButton

Cursor.Buttons

Cursor