User Tools

Site Tools

한국어

winforms:hide_mouse_cursor:index

This is an old revision of the document!


WinForms (Linux) Hiding the Mouse Cursor

The ComfileTech.WinForms implementation does not support System.Windows.Forms.Cursor.Hide. As a workaround, hide the mouse cursor by setting Form.Cursor to an invisible cursor.

if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
    Cursor = Cursors.Invisible;
}
 
public static class Cursors
{
    private static byte[] Data;
 
    //
    // Summary:
    //     An invisible cursor for use on platforms that do not support the System.Windows.Forms.Cursor.Hide
    //     method.
    public static Cursor Invisible { get; }
 
    static Cursors()
    {
        Data = new byte[326]
        {
            0, 0, 2, 0, 1, 0, 32, 32, 0, 0,
            0, 0, 0, 0, 48, 1, 0, 0, 22, 0,
            0, 0, 40, 0, 0, 0, 32, 0, 0, 0,
            64, 0, 0, 0, 1, 0, 1, 0, 0, 0,
            0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 255, 255, 255, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 255, 255,
            255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
            255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
            255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
            255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
            255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
            255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
            255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
            255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
            255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
            255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
            255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
            255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
            255, 255, 255, 255, 255, 255
        };
        Invisible = new Cursor(new MemoryStream(Data));
    }
}
winforms/hide_mouse_cursor/index.1783477029.txt.gz · Last modified: by mfranklin