CreateCursor function

Creates a cursor having the specified size, bit patterns, and hot spot.

Syntax

HCURSOR CreateCursor(
  HINSTANCE  hInst,
  int        xHotSpot,
  int        yHotSpot,
  int        nWidth,
  int        nHeight,
  CONST VOID *pvANDPlane,
  CONST VOID *pvXORPlane
);

Parameters

hInst

Type: HINSTANCE

A handle to the current instance of the application creating the cursor.

xHotSpot

Type: int

The horizontal position of the cursor's hot spot.

yHotSpot

Type: int

The vertical position of the cursor's hot spot.

nWidth

Type: int

The width of the cursor, in pixels.

nHeight

Type: int

The height of the cursor, in pixels.

pvANDPlane

Type: const VOID*

An array of bytes that contains the bit values for the AND mask of the cursor, as in a device-dependent monochrome bitmap.

pvXORPlane

Type: const VOID*

An array of bytes that contains the bit values for the XOR mask of the cursor, as in a device-dependent monochrome bitmap.

Return Value

Type: HCURSOR

If the function succeeds, the return value is a handle to the cursor.

If the function fails, the return value is NULL. To get extended error information, call GetLastError.

Remarks

The nWidth and nHeight parameters must specify a width and height that are supported by the current display driver, because the system cannot create cursors of other sizes. To determine the width and height supported by the display driver, use the GetSystemMetrics function, specifying the SM_CXCURSOR or SM_CYCURSOR value.

Before closing, an application must call the DestroyCursor function to free any system resources associated with the cursor.

DPI Virtualization

This API does not participate in DPI virtualization. The output returned is in terms of physical coordinates, and is not affected by the DPI of the calling thread. Note that the cursor created may still be scaled to match the DPI of any given window it is drawn into.

Examples

For an example, see Creating a Cursor.

Requirements

   
Windows version Windows 2000 Professional [desktop apps only] Windows 2000 Server [desktop apps only]
Target Platform Windows
Header winuser.h (include Windows.h)
Library User32.lib
DLL User32.dll

See Also

Conceptual

CreateIcon

Cursors

DestroyCursor

GetModuleHandle

GetSystemMetrics

Other Resources

Reference

SetCursor