Older Version Newer Version

JanetTerra JanetTerra Jul 3, 2011

Custom Cursors With LoadCursorFromFile

Janet Terra
Custom Cursors With LoadCursorFromFile | Changing the Cursor | Finding Custom Cursors | Setting the Cursor in the Control Panel | SetCursor vs SetSystemCursor | Static Cursors and Animated Cursors

Changing the Cursor

Mitchell Kotler wrote two articles for the Liberty BASIC Newsletters about loading Windows cursors using the 16 bit user.dll, "LoadCursor" API. The demo was written for Liberty BASIC v2. As an update to Liberty BASIC v4.x and the 32 bit user32.dll, Gordon Sweet submitted Changing the Cursor - Two Examples for the Liberty BASIC Newsletter #121. These programs temporarily change the cursor to any of 25 predefined Windows images. It is possible to temporarily change the cursor to a custom designed cursor using the user32.dll, "LoadCursorFromFile" API.

Finding Custom Cursors

This article originally appeared in the Liberty BASIC Newsletters #135 and was based upon information valid for Windows XP. The available cursors and cursor names differ in Windows 7. In either version, the cursor files are found in the C:\WINDOWS\Cursors\ directory. You may need to adjust the variable path$ if your Windows path differs. This demo loads four cursors found in the Windows\Cursors\ folder. In addition, four custom cursors, can be loaded and used. The cursors were obtained from these websites

Setting the Cursor in the Control Panel

My Computer> Control Properties> Mouse> Pointers brings up a dialog that will allow you to change the Mouse Pointer scheme. You can search the web to find numerous libraries of cursors in just about every theme imaginable. This demo DOES NOT alter or add to your computer mouse settings .

SetCursor vs SetSystemCursor

The code in this demo temporarily changes the cursor while it is over the graphicbox only. Each time the mouse moves, the call to SetCursor must be made. The cursor reverts to the original when not moving over the graphicbox. It is possible to permanently change the look of the cursor with the API call, SetSystemCursor. Be careful, though, as this call can make irreversible and unpleasant changes. This demo DOES NOT call SetSystemCursor .

Static Cursors and Animated Cursors

Static cursors end with the extension .cur . An animated cursor usually ends with the extension .avi . Both are loaded with the user32.dll "LoadCursorFromFile" API call. This demo displays both static and animated cursors. Use the Menu to sample the different icons.


Custom Cursors With LoadCursorFromFile | Changing the Cursor | Finding Custom Cursors | Setting the Cursor in the Control Panel | SetCursor vs SetSystemCursor | Static Cursors and Animated Cursors