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.Reflection;
namespace HappyFarm
{
public partial class Form4 : Form
{
public Form4()
{
InitializeComponent();
}
[DllImport("user32.dll")]
public static extern IntPtr LoadCursorFromFile(string fileName);
[DllImport("user32.dll")]
public static extern IntPtr SetCursor(IntPtr cursorHandle);
[DllImport("user32.dll")]
public static extern uint DestroyCursor(IntPtr cursorHandle);
private void Form4_Load(object sender, EventArgs e)
{
Bitmap a = (Bitmap)Bitmap.FromFile("handSmall.png");
SetCursor(a, new Point(0, 0));
}
public void SetCursor(Bitmap cursor, Point hotPoint)
{
int hotX = hotPoint.X;
int hotY = hotPoint.Y;
Bitmap myNewCursor = new Bitmap(cursor.Width * 2 - hotX, cursor.Height * 2 - hotY);
Graphics g = Graphics.FromImage(myNewCursor);
g.Clear(Color.FromArgb(0, 0, 0, 0));
g.DrawImage(cursor, cursor.Width - hotX, cursor.Height - hotY, cursor.Width, cursor.Height);
this.Cursor = new Cursor(myNewCursor.GetHicon());
g.Dispose();
myNewCursor.Dispose();
}
}
}