StrokesPlus.net
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Rob Otter  
#1 Posted : Thursday, November 26, 2020 10:49:53 PM(UTC)
Rob Otter

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 10/26/2020(UTC)
Posts: 50
Germany
Location: Darmstadt

Thanks: 15 times
Was thanked: 2 time(s) in 2 post(s)
I know there is the function sp.GetCurrentMouseCursor() - but how to set the cursor, either to a pre-defined or custom image?
And how can I get not only the current cursor but also all other ones?
As far as I found, there are two Cursor classes, System.Windows.Input.Cursor and System.Windows.Forms.Cursor - which one should I use and how can I access it from S+?

In the end, I´d like to put an overlay image on all cursors while my mouse restriction function is active.

Thanks for any tips!
Rob  
#2 Posted : Friday, November 27, 2020 4:08:14 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
System-wide cursors are a major pain to work with!

In 0.4.0.0, I added SetMouseCursor to assign a given cursor a new cursor from a .CUR or .ANI file.
Code:
sp.SetMouseCursor("Arrow", "C:\\Windows\\Cursors\\aero_arrow_xl.cur"); 

This does not update your Windows setting, so reloading Windows or calling sp.ShowMouseCursor() will reset it to the default.

This is also not a simple overlay, you would have to create/use separate cursor files for each of the 14 system cursor types listed below:

Arrow, IBeam, WaitCursor, Cross, UpArrow, SizeNWSE, SizeNESW, SizeWE, SizeNS, SizeAll, No, Hand, AppStarting, Help

See this MSDN article about creating cursors and see how they are a lot more complicated than you would think:

https://docs.microsoft.com/en-us/windows/win32/menurc/using-cursors

Now, with some WinAPI calls and C# code, you could probably extract each current cursor's image, add the overlay, save it to a file, then call the new sp.SetMouseCursor - but that would be something which will almost certainly need to written as a plug-in using C# and native WinAPI calls.

Creating a set of your own icon files, copying from the existing Windows cursor files and modifying, would probably be a much more productive and simple method. Or just using some of the other existing cursors already in Windows, like maybe the black ones if you normally use white, for example.

Calling sp.ShowMouseCursor() is the simplest way to reload all cursors to the default after you've changed them.

Edited by user Friday, November 27, 2020 4:15:50 PM(UTC)  | Reason: Not specified

thanks 1 user thanked Rob for this useful post.
Rob Otter on 11/27/2020(UTC)
Rob  
#3 Posted : Friday, November 27, 2020 4:11:58 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
Oh, and to access the .NET Framework forms cursors would be via:
Code:
forms.System.Windows.Forms.Cursor

However, that namespace mostly has to do with the cursor when it's over a .NET WinForms window, not the system cursor - so just the cursor when inside the application.

Edited by user Friday, November 27, 2020 4:14:13 PM(UTC)  | Reason: Not specified

Rob Otter  
#4 Posted : Friday, November 27, 2020 4:54:34 PM(UTC)
Rob Otter

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 10/26/2020(UTC)
Posts: 50
Germany
Location: Darmstadt

Thanks: 15 times
Was thanked: 2 time(s) in 2 post(s)
Wow. Over the last weeks, I´m constantly and deeply impressed by your lightning fast and very helpful response. I´m honestly thankful for that!

In the mean time, after studying several of your built-in examples, I found the forms wrapper object myself and from there on it was easy to find the way to the Cursor class. But having the new SetMouseCursor function will make things a lot easier!
Rob  
#5 Posted : Friday, November 27, 2020 5:01:52 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
Quote:
Wow. Over the last weeks, I´m constantly and deeply impressed by your lightning fast and very helpful response. I´m honestly thankful for that!


You're welcome!

If I could get paid to just work on this every day, I would quite happily!
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.