Attached is a project that includes two functions that allow you to change the mouse cursor within your project. These functions call on functions within the user32.dll on the windows system.
Here is an example of how to use the functions
Here are the two functions. The first function requires that you use one of the above codes to change the cursor, such as to the hourglass (32514). It will also return the default arrow key that was used before you changed the cursor. This value will be used in the second function.
The second function is used to change the cursor back to it's original state. In the example above it uses the returned value from the first function.
There are limitations to this function. If you move the mouse outside the AMS window it reverts to the normal arrow. If you mouse over anothe object within the AMS window it reverts to the normal arrow again. I hope you find this useful for your projects.
Here is a sample project.
Here is an example of how to use the functions
Code:
--[[ Use this function with one of the following codes to set the mouse to busy or other type of cursor ********************************************************************************** ** 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: resetCursor = SetCursor(32514); --do something here ReturnCursor(resetCursor)
Code:
function SetCursor(cursor) -- Get current cursor local holdCursor = DLL.CallFunction(_SystemFolder.."\\User32.dll", "GetCursor", "", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL); -- Load hourglasscursor local hCursor = DLL.CallFunction(_SystemFolder.."\\User32.dll", "LoadCursorA", "0, "..cursor, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL); -- Display loaded cursor local retVal = DLL.CallFunction(_SystemFolder.."\\User32.dll", "SetCursor", hCursor, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL); --return the holdCursor return holdCursor; end
Code:
function ReturnCursor(resCursor) -- Display original cursor local retVal = DLL.CallFunction(_SystemFolder.."\\User32.dll", "SetCursor", resCursor, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL); end
Here is a sample project.
Comment