次の方法で共有


Creating a Cursor (Windows Embedded CE 6.0)

1/6/2010

A cursor is a small bit image that reflects the position of a pointing device.

Because standard cursors are predefined, it is unnecessary to create them. To use a standard cursor, an application retrieves a cursor handle by calling the LoadCursor function. A cursor handle is a unique value of the HCURSOR type that identifies a standard or custom cursor.

The following code example shows the syntaxfor the LoadCursor function.

HCURSOR LoadCursor( 
   HINSTANCE hInstance, // Handle to the application instance
   LPCTSTR lpCursorName // Name string or cursor resource identifier
);

Here, hInstance is a handle to an instance of the module whose executable file contains the cursor to be loaded, and lpCursorName is a pointer to the name of the cursor to be loaded. It can also point to a resource identifier. To use a predefined cursor, the application must set hInstance to NULL and lpCursorName to one of the predefined cursor values.

Windows Embedded CE–based platforms implement cursors in different ways depending on the platform configuration. For example, on many Windows Embedded CE–based platforms, users interact with applications by tapping the stylus on the screen; because there is no mouse, there is no need for a cursor to indicate the current mouse position. Target platforms not requiring mouse support typically implement Iconcurs.dll. This component enables you to specify only the wait cursor when calling the LoadCursor function. Applications should display the wait cursor when executing a command that renders the current window or the system unresponsive to user input. To establish the shape of a wait cursor, you must call the SetCursor function in conjunction with the LoadCursor function. The following code example shows how to establish the shape of a wait cursor.

SetCursor(LoadCursor(NULL, IDC_WAIT));

Target platforms that support mouse cursors typically include Mcursor.dll. This component implements cursors similar to Windows-based desktop platforms; all standard cursors, except color cursors, are available when calling the LoadCursor function. Windows Embedded CE also supports custom cursors.

To create a custom cursor

  1. Draw the cursor by using a graphics application.

  2. Include the cursor as a resource in the application resource-definition file.

    Using a cursor resource avoids device dependence, simplifies localization, and enables applications to share cursor designs.

  3. Call LoadCursor at run time to retrieve the cursor handle.

    Cursor resources contain data for several different display devices. The LoadCursor function automatically selects the most appropriate data for the current display device.

Once you create and load a cursor, you can hide and redisplay the cursor, without changing the cursor design, by using the ShowCursor function. This function uses an internal counter to determine when to hide or display the cursor. An attempt to show the cursor increments the counter; an attempt to hide the cursor decrements the counter. The cursor is visible only if this counter is greater than or equal to zero.

Additionally, you can change the design of the cursor by using the SetCursor function and specifying a different cursor handle.

See Also

Concepts

Using Resources

Other Resources

GWES Application Development