using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication55
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
SetCursor(WindowsFormsApplication55.Properties.Resources.colorHand, new Point(0, 0), this);
}
/// <summary>
/// 截屏更改鼠标图标
/// </summary>
/// <param name="cursor"></param>
/// <param name="hotPoint"></param>
/// <param name="form"></param>
public static void SetCursor(Bitmap cursor, Point hotPoint, Form form)
{
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);
form.Cursor = new Cursor(myNewCursor.GetHicon());
g.Dispose();
myNewCursor.Dispose();
}
}
}