Ok, getting stuck already! This is how far I've got so far:
To discover what the (global) cursor currently is I can use:
Code:
VarSetCapacity(CurrentCursorStruct, 20, 0)
InsertInteger(20, CurrentCursorStruct, 0)
result := DllCall("GetCursorInfo", "str", CurrentCursorStruct)
hcursor := ExtractInteger(CurrentCursorStruct, 8)
Binding this to a key, I get different results for hcursor depending on the state of the cursor; this was my "calibration" test to check that I was using DllCall and structs ok. The info for the struct came from
http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/resources/cursors/cursorreference/cursorstructures/cursorinfo.asp?frame=true.
So far so good. Googling then told me that in order to change a cursor over a window, I need to replace its class cursor. The pseudo code for this is something like:
Code:
hCursor = LoadCursor(NULL, IDC_CROSS);
hPrevCursor = SetCursor(hCursor);
SetClassLong(GetWindowHandle(MyWindow), GCL_HCURSOR, hCursor)
I've attempted to get this to work (changing the cursor to a Crosshair) as follows:
Code:
CursorTest:
NULL=
GCL_HCURSOR=-12
IDC_CROSS=65571
result1 := DllCall("LoadCursor", "Uint", NULL, "Str", IDC_CROSS)
error1 = %ErrorLevel%
result2 := DllCall("SetCursor", "Uint", result1)
error2 = %ErrorLevel%
result3 := DllCall("SetClassLong", "Uint", timer_id, "Int", GCL_HCURSOR, "Uint", result1)
error3 = %ErrorLevel%
ToolTip, %result1%`t%result2%`t%result3%`n%error1%`t%error2%`t%error3%
return
The GCL_HCURSOR value I found by googling; the IDC_CROSS value is MAKEINTRESOURCE(32515) - my value could easily be wrong for this
The tooltip tells me that the first call is failing; no error, but no pointer to a cursor resource either.
Any ideas? I'll keep playing around anyway. Thanks,
Ant