.NET Core Version:
all .NET Core and Desktop Framework
Have you experienced this same bug with .NET Framework?:
Yes
Problem description:
Loading a cursor making use of alpha transparency by filename or stream does not work correctly when done through WinForms and produces a black cursor image (possibly the cursor mask instead of the actual cursor?)
WinForms is using IPicture interop to load cursors instead of the win32 cursor API and its unclear if OLE simply doesn't support alpha transparency, or if WinForms is doing something wrong in the interop.
Expected behavior:
The rendering should match the builtin hand cursor Windows uses (since in fact its the same file). You can also work around the bug by doing manual interop and calling LoadCursorFromFile. For streams this requires saving the stream to a file first, though.
Minimal repro:
Add a button and set the cursor to a file containing alpha transparency, for example the hand cursor distributed with Windows.
button1.Cursor = new Cursor(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "Cursors\\aero_link.cur"));
Not technically System.Drawing, but marking it as such as it is logically closer to Icon for this feature (so I'm more likely to notice it when looking at graphics resource related code).
.NET Core Version: all .NET Core and Desktop Framework
Have you experienced this same bug with .NET Framework?: Yes
Problem description:
Loading a cursor making use of alpha transparency by filename or stream does not work correctly when done through WinForms and produces a black cursor image (possibly the cursor mask instead of the actual cursor?)
WinForms is using
IPicture
interop to load cursors instead of the win32 cursor API and its unclear if OLE simply doesn't support alpha transparency, or if WinForms is doing something wrong in the interop.Expected behavior:
The rendering should match the builtin hand cursor Windows uses (since in fact its the same file). You can also work around the bug by doing manual interop and calling LoadCursorFromFile. For streams this requires saving the stream to a file first, though.
Minimal repro:
Add a button and set the cursor to a file containing alpha transparency, for example the hand cursor distributed with Windows.
button1.Cursor = new Cursor(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "Cursors\\aero_link.cur"));