954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Yet More cursor issues

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

nssltd
Junior Poster
124 posts since Jul 2010
Reputation Points: 31
Solved Threads: 2
 

The Cursor class does not support any animated cursors(ani files)
See this article for more info.

ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
 

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

nssltd
Junior Poster
124 posts since Jul 2010
Reputation Points: 31
Solved Threads: 2
 

Probably you have to use some Win32 API calls.

Have a look at this link: http://www.gdgsoft.com/anituner/help/aniformat.htm

samil
Newbie Poster
3 posts since Aug 2010
Reputation Points: 10
Solved Threads: 1
 

Google animated cursors in C#You will find among other stuff, this: http://www.codeproject.com/KB/GDI/anicursor.aspx

ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
 

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

nssltd
Junior Poster
124 posts since Jul 2010
Reputation Points: 31
Solved Threads: 2
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: