Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i change the cursor (image) in the whole windows OS

Tags:

c#

.net

I need to change the cursor in all windows, not just in the application, i have try this:

this.Cursor = Cursors.WaitCursor;

And this:

System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

But it only changes the cursor in my application.

Any idea?

like image 343
Fernando Santiago Avatar asked Feb 22 '13 03:02

Fernando Santiago


People also ask

How do I get a custom cursor for everything?

Customizing cursors Step 1: Navigate to the Mouse properties window as we did earlier. Step 2: Select the Pointers tab. Step 3: To select a custom cursor for the highlighted individual icon, click Browse. Step 4: That will open the default cursors folder, where hundreds of different cursor options are available.


1 Answers

Assuming you have your own cursor file (.cur) to apply you could hack this.

First you will have to change thje default Arrow cursor in the Registry, then you will need to call some P-Invoke to allow the OS to update the current sytem paramerters so the cursor actually changes.

Somthing like:

    private void ChangeCursor(string curFile)
    {
        Registry.SetValue(@"HKEY_CURRENT_USER\Control Panel\Cursors\", "Arrow", curFile);
        SystemParametersInfo(SPI_SETCURSORS, 0, null, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE); 
    }

    const int SPI_SETCURSORS = 0x0057; 
    const int SPIF_UPDATEINIFILE = 0x01; 
    const int SPIF_SENDCHANGE = 0x02; 

    [DllImport("user32.dll", EntryPoint = "SystemParametersInfo")]
    public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, uint? pvParam, uint fWinIni);

Usage:

 ChangeCursor(@"C:\MyCursor.cur");
like image 87
sa_ddam213 Avatar answered Oct 21 '22 14:10

sa_ddam213