0

You know you'd think it be the easiest thing in the WORLD to change the cursor, after all its just an image but yet again i'm having problems.I am making a web browser project I have the standard cursor( . cur file ) and when the application is navigating i want it to show a custom ani file i made in axialis icon workshop but im not sure how to add it in to my project. so far i know i need to import user32.dll into my project. but so far thats it. Can any one help me?

Any help is much appreciated,

NSSLTD

3
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by nssltd
0

Seriously that is odd, so theres no way to use .ani's then. i was just wondering how windows did it then?

0

Dear users i have found out how to use animated cursors in c#
i found out the answer from this article here
here is the code i used
NOTE: blob is an animated cursor i created.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;

namespace anitest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            try
            {
                this.Cursor = AdvancedCursors.Create(Path.Combine(Application.StartupPath, "blob.ani"));
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }

        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        public class AdvancedCursors
        {

            [DllImport("User32.dll")]
            private static extern IntPtr LoadCursorFromFile(String str);

            public static Cursor Create(string filename)
            {
                IntPtr hCursor = LoadCursorFromFile(filename);

                if (!IntPtr.Zero.Equals(hCursor))
                {
                    return new Cursor(hCursor);
                }
                else
                {
                    throw new ApplicationException("Could not create cursor from file " + filename);
                }
            }

        }
    }
}

Use it wisely :D

NSSLTD

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.