using System.Runtime.InteropServices; #region 设置鼠标指针
[DllImport("user32")]
private static extern IntPtr SetCursor(IntPtr hCursor);
[DllImport("user32")]
private static extern IntPtr LoadCursorFromFile(string lpFileName);
const int WM_SETCURSOR = 0x0020; private void Form1_Load(object sender, System.EventArgs e)
{
IntPtr hCursor;
hCursor=LoadCursorFromFile("ico.cur");
SetCursor(hCursor);
} protected override void WndProc(ref System.Windows.Forms.Message m)
{
switch(m.Msg)
{
case WM_SETCURSOR:
IntPtr hCursor;
hCursor=LoadCursorFromFile("ico.cur");
SetCursor(hCursor);
break;
default:
base.WndProc(ref m);
break;
}
}
#endregion上面的代码能自定义程序中鼠标指针样式,但当鼠标移动至随便一个控件上时,鼠标样式无效,而在from本身窗体上才有效,为什么?谁能帮忙修改一下,谢谢