I agree this is not ideal, I created a feedback case to get Xojo to add the cursor to the Cursors type. It literally would be the exact same code as the Wait cursor except they’d send 32650 to the LoadCursorW function instead of 32514.
I can’t worry about what future versions of Windows will bring - When a new OS breaks something, we patch the software, that’s how it’s always worked. But the reason the mouse cursor is important is:
How does the user know they can click the cancel button here? And where is the hotspot of the mouse? Is it in the top left? Center? Everything is a guess from the user’s perspective. The solution is already built into the Windows API, we just can’t access it from a Xojo window.
Appreciate the help though, cheers and best of luck with your projects on Win11. I’ve had some frustrations with the OS as well (which is why I haven’t upgraded my personal system yet).
How does the user know they can click the cancel button here?
the area of popup where the user get information that he must wait get the wait cursor.
if the user move the mouse over other ui he could get this default pointer.
or
you would use a progress bar or progress wheel and let the mouse a arrow if your app is accessible.
This project allow the user to change the ListBox MouseCursor, using one of the System.Cursors OR Custom.
What is Custom in this context ?
The code takes the Clipboard available Picture and convert it as a cursor (I made a copy of and get that as a cursor (RAW Cursor, whith white background since it was only to recall how this project worked).
Of course, this MouseCursor change when the Mouse is ut of the ListBox.
I do not tried to create a multiple Picture object, so I do not know if this work.
I wrote that on January 22nd, 2022, and run it now with Xojo 2022r2 (m1 MacBookPro / Monterey 12.5). The code is some lines only (including tests)… but warning: you can pass a large image asa MouseCursor (on macOS, not tested on WIndows) by error, so limit the picture size.
Case "Custom"
Dim Clip As New Clipboard
Dim Curs_Pict As New Picture(40,40)
If Clip.PictureAvailable Then
Curs_Pict = Clip.Picture
Clip.Close
Dim thisMouse As New MouseCursor(Curs_Pict, 0, 0)
Me.MouseCursor = thisMouse
End If
Remember: in my code above, I use a ScreenShot I’ve done before I click in Custom (last line of the first screen shot above).
Thus my question above: what do not worked for you ?
It’s a special animated (usually) cursor provided by Windows. It matches the theme that the user’s system is set to, so it’s not just as simple as providing your own custom cursors, you would need to read the registry to determine the filename of cursor the current system theme is using, then read that file containing that cursor, which could be in one of a few different file formats. Then possibly animate it.
In other languages like .Net it is one of the mouse cursor constants alongside Wait and can be done in one line.
I followed your advice, but I am not sure that I get an animated cursor. Here is the used code (the images are in the folder (watch the folder screen shot above):
Sub Action() Handles Action
Var dlg As New SelectFolderDialog
dlg.ActionButtonCaption = "Select"
dlg.Title = "Title Property"
dlg.PromptText = "Prompt Text"
dlg.InitialFolder = SpecialFolder.Documents
Var f As FolderItem
f = dlg.ShowModal
If f = Nil Then
// User cancelled
Return
End If
Var Pict(6) As Picture
Var Pict_Idx As Integer
Var Loop_Idx As Integer
Var Fldr_Cnt As Integer = f.Count - 1 // .DS_Store
Var Curs_FI As FolderItem
For Loop_Idx = 0 To Fldr_Cnt
Curs_FI = f.ChildAt(Loop_Idx)
If Curs_FI.Name <> ".DS_Store" Then
Pict(Pict_Idx) = Picture.Open(Curs_FI)
Pict_Idx = Pict_Idx + 1
End If
If UserCancelled Then Exit
Next
Var Pictu As New Picture(19,30, Pict) // Now the Pict array is populated…
Var thisMouse As New MouseCursor(Pictu, 0, 0)
Self.MouseCursor = thisMouse
End Sub
The cursor is the “gris” one and I do not saw any animation, but I do not say there is not, just I do not saw it if there is one (ONE, not continuously).
I think so. AFAIK the picture array is for different DPI settings. Maybe Xojo chooses the right picture to display a mouse cursor with a higher resolution but does not animate it.
I do not think so. They use it that way, but we always been able to load multi Picture files and display their contents (separateley)…
I remember using load Picture and Picture (Index) to get their png, jpg, tiff contents.
After some minutes, I realized that there is no way to tell Xojo to animate the files (cursors here), so how can it be animated at display time …
The height and width are in points. The bitmaps are copied upon creation. All bitmaps must have the same aspect ratio. A bitmap’s DPI will be calculated from the point size and the bitmap’s size in pixels. Pictures created using this constructor have their Type set to Types.Image.
You can animate a mouse cursor setting it’s image via timer. You should do that as App.MouseCursor = …
The picture array parameter in the Picture constructor is not the frames of an animation. As Carsten says, it is for supplying multiple bitmap resolutions for the “same” picture.
As Christian and Carsten observe, the way to animate cursor is by loading pic sequence, creating MouseCursor sequence (array), then looping through that with a timer.
Something like this …
Disclaimer: knocked up very quickly, no error checking, very crude just to show the basic idea, and only tested on my Mac.
ok, at least you can make a folder here and change the mouse appearance
at your need if you host your own software.
so you could replace the default wait cursor.