SetCursor Function

Declare Function SetCursor Lib "user32.dll" (ByVal hCursor As Long) As Long

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

SetCursor sets the image used to represent the mouse cursor. The new cursor can be any valid cursor that has either been created or loaded. If successful, the function returns a handle to the old cursor image. If unsuccessful, the function returns 0.

hCursor
The handle to the new cursor to use to represent the mouse pointer.

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: GetCursor, SetSystemCursor
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/s/setcursor.html