Changing the cursor

BlitzPlus Forums/BlitzPlus Programming/Changing the cursor

I have an API call for user32.dll but I'm not quite sure how to use it... If someone could help me I would really appreciate it :)

.lib "user32.dll"

API_LoadCursor%(ID,Cursor):"LoadCursorA" 
API_SetCursor%(ID):"SetCursor"


Here, I found this topic:
http://www.blitzbasic.com/Community/posts.php?topic=33747

you can also change the system cursor:
;.lib "user32.dll"
;
;api_DestroyCursor% (hCursor%) : "DestroyCursor"
;api_SetSystemCursor% (hcur%, id%) : "SetSystemCursor"
;api_CreateCursor% (hInstance%, nXhotspot%, nYhotspot%, nWidth%, nHeight%, lpANDbitPlane*, lpXORbitPlane*) : "CreateCursor"
;api_LoadCursor% (hInstance%, lpCursorName%) : "LoadCursorA"
;-----------------------



;!if you run this program, the cursor will change
;even after the program is done!
;you can go to (windows) START->SETTINGS->MOUSE-> and 
;change the scheme to change it back.

Graphics 800, 600, 0, 2

bank1 = CreateBank(32)
bank2 = CreateBank(32)

;this is a bitmap, which means 8 pixels are stored in a single number
;i wrote the bits separately, you can replace them with a zero to make them black
For j = 0 To 15
For i = 0 To 1
    ;color 1 (AND)
	PokeByte bank1, j + i * 16, 1 + 2 + 4 + 8 + 16 + 32 + 64 + 128
	;color 2 (OR)
	PokeByte bank2, j + i * 16, 1 + 2 + 4 + 8 + 16 + 32 + 64 + 128
Next
Next

;create cursor
cursor = api_CreateCursor(0, 0, 0, 16, 16, bank1, bank2)
api_SetSystemCursor(cursor, 32512)

WaitKey()

api_DestroyCursor(cursor)

FreeBank bank1
FreeBank bank2

End


That's cool, but what's the ID% part of it for exactly?

'ID' is the handle, an integer value. I think it is the adress in memory where the cursor is stored.
The first parameter of LoadCursor is 'hInstance' not 'id', it is a handle for a window. That is also an integer value that identifies the window in Windows.
http://blogs.msdn.com/oldnewthing/archive/2005/04/18/409205.aspx

edit:
just realized you ment id in the previous code ..
So that ID is which cursor you want to redefine. There are several types of cursors: point, hourglass etc. Each cursor has an ID code:
http://msdn2.microsoft.com/en-us/library/ms648395.aspx
On msdn, they're called OCR_APPSTARTING, OCR_NORMAL, OCR_CROSS etc, but these are consts which means they represent numbers:
http://www.autoitscript.com/forum/lofiversion/index.php?t22214.html
(3rd post in the thread, found it by google search: const OCR_NORMAL)