Hi well i posted a earlier thread but no one has replied in three days i have one reply, but it's not what i wanted.

he cursor i am using is one from axialis cursor workshop examples. it is a .cur and it does work as i have changed my windows default cursors to them. it is a colored cursor blue if you want to see it find it here
i have used these methods;

this.Cursor = new Cursor(GetType(), "a.cur");
Cursor myCursor = new Cursor("myCursor.cur");
MyControl1.Cursor = myCursor
IntPtr ptr = IMP.Properties.Resources.zoom_in.GetHicon();
Cursor c = new Cursor(ptr);
this.Cursor = c;

The last method does work but you need to put the ENTIRE image/Cursor over the component IE button. also you need to use an image file. What i would like to achieve would be to use a .cur/.ani file on a windows form that my cursor
(here)will become the cursor on my form instead of the windows default one

Any help is MUCH appreciated

Thanks in advance,


6 Years
Discussion Span
Last Post by nssltd

What exactly is the problem when you try to use the .cur file?
Does it not load or does it load incorrectly? Bear in mind that the Cursor class only supports black and White cursors:

Note The Cursor class does not support animated cursors (.ani files) or cursors with colors other than black and white.
from msdn Cursor Class


Just found this that might be of interest. It shows how to load a bitmap as a custom cursor and include a hotspot. Setting the hotspot should resolve the issue you have with needing to place the whole image over a control to interact with it.


hi well it works but it wont let me add any components to the form! and i cannot find the part of the code that prevents adding components the form! i'll post the code down and see if anyone can help me

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace CursorTest
  public struct IconInfo
    public bool fIcon;
    public int xHotspot;
    public int yHotspot;
    public IntPtr hbmMask;
    public IntPtr hbmColor;

  public class CursorTest : Form
      private Button button1;
    public CursorTest()
      this.Text = "Cursor Test";

      Image newImage = Image.FromFile("Familly.png");

      Pen p;
      SolidBrush b, bT = new SolidBrush(Color.Black);
      Graphics gr = Graphics.FromHwnd(this.Handle);
      Color cP = Color.Gray;
      Color cB = Color.LightGray;
      p = new Pen(cP, 6);
      b = new SolidBrush(cB);


      // Create Point for upper-left corner of image.
      Point ulCorner = new Point(0, 0);
        Bitmap bitmap = new Bitmap(140, 25);
      Graphics g = Graphics.FromImage(bitmap);
      using (Font f = new Font(FontFamily.GenericSansSerif, 10))
          g.DrawImage(newImage, ulCorner);
      this.Cursor = CreateCursor(bitmap, 3, 3);


    public static extern IntPtr CreateIconIndirect(ref IconInfo icon);
    [return: MarshalAs(UnmanagedType.Bool)]
    public static extern bool GetIconInfo(IntPtr hIcon, ref IconInfo pIconInfo);

    public static Cursor CreateCursor(Bitmap bmp, int xHotSpot, int yHotSpot)
      IntPtr ptr = bmp.GetHicon();
      IconInfo tmp = new IconInfo();
      GetIconInfo(ptr, ref tmp);
      tmp.xHotspot = xHotSpot;
      tmp.yHotspot = yHotSpot;
      tmp.fIcon = false;
      ptr = CreateIconIndirect(ref tmp);
      return new Cursor(ptr);

    private void InitializeComponent()
        this.button1 = new System.Windows.Forms.Button();
        // button1
        this.button1.Location = new System.Drawing.Point(-6, 1);
        this.button1.Name = "button1";
        this.button1.Size = new System.Drawing.Size(91, 84);
        this.button1.TabIndex = 0;
        this.button1.Text = "button1";
        this.button1.UseVisualStyleBackColor = true;
        // CursorTest
        this.ClientSize = new System.Drawing.Size(284, 262);
        this.Name = "CursorTest";
        this.Load += new System.EventHandler(this.CursorTest_Load);


    private void CursorTest_Load(object sender, EventArgs e)


You've missed out InitializeComponent from the form constructor.

Edited by nick.crane: n/a

Votes + Comments
exactly it :p

Oh my i have what an stupid mistake... sorry to have bothered you. im really shocked i missed that.
Thanks for pointing out my error!


Thanks everyone my cursor problems are solved... thanks to everyone that helped.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.