LoadCursor Function

Declare Function LoadCursor Lib "user32.dll" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As Any) As Long

Platforms: Win 32s, Win 95/98, Win NT

LoadCursor loads a cursor from either a currently running program's cursor resources or Windows's cursor resources. The cursor can be referenced either by its resource name or by its numeric resource ID number. If successful, the function returns a handle to the loaded cursor. If unsuccessful, the function returns 0.

hInstance
To load one of a program's cursor resources, set this to the application's instance handle. To load one of Windows's cursor resources, set this to 0.
lpCursorName
Either a string containing the name of the cursor resource to load, or a numeric ID number identifying the resource. For Windows's cursors, exactly one of the following flags can be used to select the desired cursor resource:
IDC_APPSTARTING = 32650
The application starting cursor (arrow and hourglass).
IDC_ARROW = 32512
The regular arrow pointer cursor.
IDC_CROSS = 32515
The cross cursor.
IDC_IBEAM = 32513
The I-shaped beam cursor (text editing cursor).
IDC_ICON = 32641
Win NT only: An empty cursor.
IDC_NO = 32648
The "no" symbol cursor (circle with a slash).
IDC_SIZE = 32640
Win NT only: The four-pointed resize/move arrow.
IDC_SIZEALL = 32646
The four-pointed resize/move arrow.
IDC_SIZENESW = 32643
The double-pointed resize arrow pointing to the upper-right and lower-left.
IDC_SIZENS = 32645
The double-pointed resize arrow pointing up and down.
IDC_SIZENWSE = 32642
The double-pointed resize arrow pointing to the upper-left and lower-right.
IDC_SIZEWE = 32644
The double-pointed resize arrow pointing left and right.
IDC_UPARROW = 32516
The up-arrow cursor.
IDC_WAIT = 32514
The wait cursor (hourglass).

Example:

' Display the application starting (arrow and hourglass) Windows
' cursor for three seconds.  The cursor resource is loaded from Windows.  Then
' restore the old cursor (whatever it happens to be).
Dim hcursor As Long  ' receives handle to application starting cursor
Dim holdcursor As Long  ' receives handle to previously used cursor
Dim retval As Long  ' throw-away return value

hcursor = LoadCursor(0, IDC_APPSTARTING)  ' load Windows's application starting cursor
holdcursor = SetCursor(hcursor)  ' set it to the new cursor
Sleep 3000  ' wait for 3 seconds
retval = SetCursor(holdcursor)  ' set it to the previous cursor

See Also: LoadCursorFromFile
Category: Cursor

Go back to the alphabetical Function listing.
Go back to the Reference section index.


This page is copyright © 2000 Paul Kuliniewicz. Copyright Information.
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/l/loadcursor.html