
{filelink=16661}
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;
public class ChargerAnimation : Form
{
public ChargerAnimation()
{
InitializeComponent();
try
{
string fichierAnimation = "Ballon.ani";
this.Cursor = CurseurPersonnalise.CreerCurseur(Path.Combine(Application.StartupPath, fichierAnimation));
}
catch (Exception err)
{
MessageBox.Show(err.Message);
}
}
private void InitializeComponent()
{
this.SuspendLayout();
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(292, 266);
this.Text = "ChargerAnimation";
this.ResumeLayout(false);
}
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new ChargerAnimation());
}
}
public class CurseurPersonnalise
{
[DllImport("User32.dll")]
private static extern IntPtr LoadCursorFromFile(String str);
public static Cursor CreerCurseur(string nomFichier)
{
IntPtr hCursor = LoadCursorFromFile(nomFichier);
if (!IntPtr.Zero.Equals(hCursor))
{
return new Cursor(hCursor);
}
else
{
throw new ApplicationException("Impossible de créer un curseur dans le fichier " + nomFichier);
}
}
}